在UIScrollView中的UIWebView上方的UIToolbar(UIToolbar above UIWebView inside UIScrollView)

编程入门 行业动态 更新时间:2024-10-27 00:26:59
UIScrollView中的UIWebView上方的UIToolbar(UIToolbar above UIWebView inside UIScrollView)

我想在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.

更多推荐

本文发布于:2023-08-04 22:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UIScrollView   UIWebView   UIToolbar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!