定制的UIView类的UIScrollView与UITableView的
问题描述:
我想在一个UIViewController添加三个观点,定制的UIView类的UIScrollView与UITableView的
- 的UIImageView
- 滚动段控制(HMSegmentedControl)
- UIViews(或)UITableviewCells
当整个视图滚动段控件时,应该将其固定在屏幕顶部(如UITableview中的标题)。
我的代码
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ((long)scrollView.tag == 10) {
// Main scrollview
if (self.lastContentOffset >= scrollview.contentOffset.y) {
NSLog(@"Down");
if (scrollview.contentOffset.y < 158.0f) {
[scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, scrollview.contentOffset.y)];
[matchInfoTable setScrollEnabled:NO];
[scrollview setScrollEnabled:YES];
}
} else if (self.lastContentOffset <= scrollview.contentOffset.y) {
NSLog(@"Up");
NSLog(@"%f",scrollview.contentOffset.y);
if (scrollview.contentOffset.y > 138.0f) {
[scrollview setScrollEnabled:NO];
[matchInfoTable setScrollEnabled:YES];
}
if (scrollview.contentOffset.y >= 163.0f) {
[scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, 163.0f)];
[scrollview setScrollEnabled:NO];
[matchInfoTable setScrollEnabled:YES];
}
}
self.lastContentOffset = scrollview.contentOffset.y;
NSLog(@"LastOffset :: %f",self.lastContentOffset);
} else if (scrollView.tag == MATCH_INFO) {
// match info table
if (scrollView.contentOffset.y == 0) { // TOP
[scrollview setContentOffset:CGPointMake(scrollview.contentOffset.x, scrollview.contentOffset.y)];
[matchInfoTable setScrollEnabled:NO];
[scrollview setScrollEnabled:YES];
}
}
}
在该代码时,在顶部的段控制引脚。下面的视图不会连续滚动。我需要再次触发它的滚动。
所有的答案赞赏!
答
我认为你应该更好地使用UIPageViewController并放入所有的tableviews,然后你可以检测到滑动和更改选项卡。
您也可以使用UISwipeGestureRecognizer并检测在这个岗位描述左,右刷卡left and right swipes