开发者

How can I make the navigation bar scroll along with my webpage?

开发者 https://www.devze.com 2023-02-22 10:19 出处:网络
How can I make the navigation bar hide as the user scrolls? I\'m trying to implement a browser like the Safari Mobile app.

How can I make the navigation bar hide as the user scrolls? I'm trying to implement a browser like the Safari Mobile app.

note:

I'm using UIWebView and not a 开发者_StackOverflow中文版UIScrollView.


If you are using a UIScrollView then you can hide navigation bar in scroll view's delegate-

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.navigationController.navigationBar setHidden:TRUE];
}


The standard approach used to be to add your view as a subview of the webview, and change the webview's contentInset property to shift everything in the webview downwards. I'm not sure if that still works with iOS 4.3.

Alternatively, if you search on SO, you'll find lots of questions the same as this one, with a variety of answers that may work, e.g.:

How to set content offset and content size in a UIWebView

iphone: View on top of UIWebView?


Put the navigation bar inside the scroll view. In other words, make the scrollview your view controllers view.

0

精彩评论

暂无评论...
验证码 换一张
取 消