我想在iPhone上隐藏两个滚动条.当我向上滚动时,他们应该再次出现..我该如何处理?
解决方法
接受的答案对我来说不起作用,因为scrollViewWillBeginScroll:不是委托方法.
相反我做
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [[NSNotificationCenter defaultCenter] postNotificationName:@"BaRSShouldHide" object:self]; } -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { if(!decelerate) [[NSNotificationCenter defaultCenter] postNotificationName:@"BaRSShouldUnhide" object:self]; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [[NSNotificationCenter defaultCenter] postNotificationName:@"BaRSShouldUnhide" object:self]; }
应用程序对象中的任何地方都可以收听此通知,例如
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addobserverForName:@"BaRSShouldHide" object:nil queue:nil usingBlock:^(NSNotification *note) { //hide tab bar with animation; }]; [[NSNotificationCenter defaultCenter] addobserverForName:@"BaRSShouldUnhide" object:nil queue:nil usingBlock:^(NSNotification *note) { //Unhide tab bar with animation; }]; }
此代码将隐藏任何滚动条.如果你想只有下来,同一个位置处理技巧在接受的答案应该工作.