将导航栏添加到选项卡栏应用程序中的 Web 视图
我在 IB 中构建了带有三个选项卡的选项卡栏应用程序。第三个选项卡愉快地显示了一个 UIWebview,您可以在其中浏览。唯一缺少的是后退按钮,因为并非所有网页都提供这样的链接。
我需要一个导航栏正确连接到正确的类。我仍然有点不确定层次结构在界面生成器中的具体外观以及如何正确连接它。
目前,第三个选项卡连接到“thirdviewcontroller”类中名为“webnews”的引用出口,并且 UIWebView(在层次结构中的普通 IUView 下,依次位于第三个选项卡栏控制器下)连接到网络新闻渠道。
如何让导航栏控制 webview,以及是否向thirdviewcontroller.m 添加代码,让视图上的导航栏控制 webview“后退”功能?作为代表我该做什么?目前我有一个应用程序委托,但它连接到选项卡栏。
我并不真正追求特定的代码,而是追求一般的“它是如何工作的”线索:)(除非我可以动态地将导航栏添加到正在运行的应用程序中......但我不认为在thirdviewcontroller中的viewWillAppear {}上添加SubView .m 将创建正确的功能?)
如果我猜测最简单的解决方案,我猜会创建一个 navbarcontroller.h/.m,在 IB 中的视图上放置一个导航栏,将第三个选项卡连接到 navbarcontroller,将navbar 到 webview (?) 并将 webnews 出口移动到 navbarcontroller.h,并将 webview 连接到它。但我不太有勇气去尝试,最好先征求意见。
I've built the tab bar application in IB, with three tabs. The third tab happily displays a UIWebview where you can browse. The only thing missing is a back button, as not all web pages supply such a link.
I need a navigation bar hooked up properly to the correct classes. I'm still a bit unsure about exactly how the hierarchy should look in interface builder and how to hook it up properly.
Currently, the third tab is hooked up to a referencing outlet called 'webnews' in the class 'thirdviewcontroller', and the UIWebView (under a normal IUView in the hierarchy, which in turn is under the third tab bar controller) is connected to the webnews outlet.
How do I make the navbar control the webview, and do I add code to the thirdviewcontroller.m that lets the navbar on the view control the webview 'back' function? What do I hook up as the delegate for it? Currently I have an app delegate, but that's hooked up to the tab bar.
I'm not really after specific code as much as a general 'how it works' clue :) (Unless I can just add the navbar dynamically to the functioning app... but I don't think addSubView on viewWillAppear {} in thirdviewcontroller.m will create the proper functionality?)
If I were to guess at the simplest solution, I'd guess create a navbarcontroller.h/.m, slap a navbar on the view in IB, connect the third tab to navbarcontroller, connect the navbar to the webview (?) and move the webnews outlet to navbarcontroller.h, and connect the webview to it. But I don't quite have the nerve to try, better to ask advice first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答这个问题,请参阅类似的 检测并处理或覆盖,单击导航栏
Answering this, see similar Detect and handle, or override, clicks on a navigation bar