How can I make the navigation bar scroll along with my webpage?
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.
精彩评论