如何判断UIScrollView滚动方向
1个回答
2016-01-15 · 知道合伙人软件行家
关注
展开全部
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
int currentPostion = scrollView.contentOffset.y;
if (currentPostion - _lastPosition > 20 && currentPostion > 0) { //这个地方加上 currentPostion > 0 即可)
_lastPosition = currentPostion;
NSLog(@"ScrollUp now");
[self hideTabBar:YES];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
else if ((_lastPosition - currentPostion > 20) && (currentPostion <= scrollView.contentSize.height-scrollView.bounds.size.height-20) ) //这个地方加上后边那个即可,也不知道为什么,再减20才行
{
_lastPosition = currentPostion;
NSLog(@"ScrollDown now");
[self hideTabBar:NO];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
}
{
int currentPostion = scrollView.contentOffset.y;
if (currentPostion - _lastPosition > 20 && currentPostion > 0) { //这个地方加上 currentPostion > 0 即可)
_lastPosition = currentPostion;
NSLog(@"ScrollUp now");
[self hideTabBar:YES];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
else if ((_lastPosition - currentPostion > 20) && (currentPostion <= scrollView.contentSize.height-scrollView.bounds.size.height-20) ) //这个地方加上后边那个即可,也不知道为什么,再减20才行
{
_lastPosition = currentPostion;
NSLog(@"ScrollDown now");
[self hideTabBar:NO];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询