我想在UIWebView上方显示一个工具栏,但隐藏工具栏,直到该人“拉下它”。
在iPhone上的Safari中可以看到相同的功能。 页面加载时,隐藏包含地址的工具栏。 你必须把它拉下来。 在Safari中,可以向上滚动并最终查看工具栏或向下滚动页面内容。
我已经尝试在UIScrollView中放置UIToolbar和UIWebView但它不起作用。 我已经尝试将UIScrollView设置为工具栏和webview的大小,但这不起作用。
- (void)viewDidLoad{ CGSize size = CGSizeMake(webView.frame.size.width, toolBar.frame.size.height + webView.frame.size.height); [scrollView setContentSize:size]; }我该怎么做呢?
编辑
任何看到此问题的人都应该考虑问题和接受的答案都是旧的,并且API可能已经更改为允许这样做。
I'd like to display a toolbar above a UIWebView but hide the toolbar until the person "pulls it down".
The same functionality can be seen in Safari on the iPhone. When the page loads, the toolbar containing the address is hidden. You must pull it down. In Safari it's possible to scroll up and eventually see the toolbar or scroll down through the page contents.
I've tried placing a UIToolbar and UIWebView inside a UIScrollView but it didn't work. I've tried setting the UIScrollView to the size of the toolbar and webview combined, but that didn't work.
- (void)viewDidLoad{ CGSize size = CGSizeMake(webView.frame.size.width, toolBar.frame.size.height + webView.frame.size.height); [scrollView setContentSize:size]; }How should I go about doing this?
EDIT
Anyone looking at this should consider that the question and accepted answer are both old and that the API might have changed to allow this.
最满意答案
UIWebView本身就是一个UIScrollView,所以它不会起作用。 我不确定Apple是如何做到这一点的,但是如果你能控制Web视图的内容,那么一种方法就是编写一些复制该地址栏的HTML和CSS。
The UIWebView is itself a UIScrollView so it's not going to work. I'm not sure how Apple does it, but one way to do it, if you have control over the content of the web view, is to write some HTML and CSS that replicates that address bar.
更多推荐
发布评论