使用此方法隐藏状态栏:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
当将"隐藏"设置回NO时,点击滚动到顶部(在UIWebView,UITableView中,无论如何)都不再起作用,并且需要重新启动应用程序才能恢复功能.
这是一个错误(无论如何我提交了一个rdar)还是我错过了一步?我是否应该期待这种行为,因为statusBar以某种方式与相应的视图"失去联系"?
重新显示后,您可以尝试再次将ScrollsToTop属性设置为true:
[currentView setScrollsToTop:YES];
如果那不起作用,你肯定只展示一个视图吗?如果有多个滚动视图,则忽略scrollViewDidScrollToTop消息...
在iOS 5.0中,您可以访问UIWebView的scrollview属性
webView.scrollView.scrollsToTop = YES;
The following fix by Alex worked for me. Thanks!
((UIScrollView *)[[webView subviews] objectAtIndex:0]).scrollsToTop = NO;
Being in a hurry this fix worked great, however given more time I might've subclassed the UIWebView and accessed the protected UIScrollView member directly.
The worry I have with Alex' method is that it assumes that UIScrollView is at index zero of the subviews (encapsulation allows private members to change). Which suggests another solution still:
for (UIView* v in [webView subviews]) { if ([v isKindOfClass:[UIScrollView class]]) { (UIScrollView *)v.scrollsToTop = NO; } }
您可以使用以下代码进行UIWebView
忽略scrollToTop
而无需额外的UIScrollView
:
((UIScrollView *)[[webView valueForKey:@"_internal"] valueForKey:@"scroller"]).scrollsToTop = NO;
我遇到了类似的问题,滚动到顶部的功能丢失了.事实证明,只有在一次只有一个活动视图时(在同一个滚动视图中),这才会起作用.在我的情况下,我有一个表视图和另一个淡入/淡出的视图.removeFromSuperview
在动画结束时添加一个诀窍.
答案在UIScrollView.h
文件评论中:
/* this is for the scroll to top gesture. by default, a single scroll visible scroll view with this flag set will get the call. if there is more than one visible with this flag set or the delegeat method returns NO, the view isn't scrolled */ @property(nonatomic) BOOL scrollsToTop; // default is YES. if set, special gesture will scroll to top of view after consulting delegate