iPhone - Make a UIWebView subview scrolling to top when user touches the status bar (iOS 4)

☆樱花仙子☆ 提交于 2019-12-04 17:41:04
[yourPaginatedScrollView setScrollsToTop:NO];
[(UIScrollView *)[yourWebView.subviews objectAtIndex:0] setScrollsToTop:YES];

The first line is important too else two scrollviews will be assigned => iOS can't really choose, so it'll decide no scrollview scrolls to top when you touch the status bar.

  1. If you are building your application against iOS 5 base SDK, you can use now public property "scrollView" in UIWebView, using that you can scroll to whatever offset you desire to.

  2. If you are building for SDK < 5.0, it can be done in another way using HTML features. You can use Anchor tag somewhere at the top in your HTML code, at the very beginning just after tag begins, include this anchor:

    < A NAME="top_of_page">

Now when user taps on the the status bar, make this action trigger:

<A HREF="#top_of_page">

Somehow, not pretty sure how though!

Perhaps by using:

- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script

???

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!