- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
lastOffset = scrollView.contentOffset;
if (scrollView.contentOffset.y < lastOffset.y) {
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];
}
else {
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setToolbarHidden:NO animated:YES];
}
}
我做错了什么? UIScrollViewDelegate 已在我的头文件中设置。
最佳答案
你应该移动
lastOffset = scrollView.contentOffset;
到方法结束,否则
scrollView.contentOffset.y < lastOffset.y
永远不会是真的。
关于ios - 当 UIScrollView 滚动时,导航和工具栏不会隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12184865/