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

夙愿已清 提交于 2019-12-25 03:53:51

问题


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 UIScrollView.


回答1:


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?




回答2:


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];
}



回答3:


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



来源:https://stackoverflow.com/questions/5575595/how-can-i-make-the-navigation-bar-scroll-along-with-my-webpage

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