문제

I have a really long UIWebView, and I need to add a way for the user to tap the UINavigationBar to scroll to top (something like the Facebook app, where it's little glow when you tap).

How can I do this?

도움이 되었습니까?

해결책

In iOS5, you can now access the UIScrollView directly, allowing you to scroll to top.

[webView.scrollView scrollRectToVisible:animated:]

That should take care of everything that you need.

다른 팁

You could use javascript to scroll the web view to the top. You could execute the javascript from the Objective-C side using

- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top