使用UINavigationBar而不使用UINavigationController [英] using UINavigationBar without UINavigationController

查看:62
本文介绍了使用UINavigationBar而不使用UINavigationController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的UIWebView顶部使用UINavigationBar,但我想手动控制标题,后退按钮,后退按钮的功能 - 等等。换句话说,我从不想推送或弹出视图。我只想在用户点击Web视图时更改UINavigationBar内容。

I want a UINavigationBar at the top of my UIWebView but I want to control by hand the title, the back button, what the back button does - etc. In other words I never want to push or pop views. I just want to change the UINavigationBar contents as the user clicks around the web view.

我在那里将UINavigationBar添加到我的superView并使其高44像素。由于我没有navigationItem,如何设置标题?我该怎么设置一个假的后退按钮?

Where I'm up to is I added the UINavigationBar to my superView and made it 44 pixels tall. How do I set the title since I have no navigationItem? How would I set a fake back button up?

我很感激任何指针。我意识到这很奇怪我正在做什么。

I would appreciate any pointers. I realise this is quite weird what I'm doing.

谢谢:)

推荐答案

如果有兴趣的话,答案就在UINavigationBar的类引用中。

The answer, if anyone's interested, is in the class reference of UINavigationBar.


当你使用导航栏作为独立对象,你是
负责提供其内容。 与其他类型的观看不同,
您不直接将子视图添加到导航栏。相反,您使用
导航项(UINavigationItem类的实例)到
指定要显示的按钮或自定义视图。导航
项目具有用于指定导航栏左侧,右侧和
中心的视图以及用于指定自定义提示
字符串的属性。

When you use a navigation bar as a standalone object, you are responsible for providing its contents. Unlike other types of views, you do not add subviews to a navigation bar directly. Instead, you use a navigation item (an instance of the UINavigationItem class) to specify what buttons or custom views you want displayed. A navigation item has properties for specifying views on the left, right, and center of the navigation bar and for specifying a custom prompt string.

简而言之,使用UINavigationItem并在UINavigationBar上通过pushNavigationItem应用它。

In short, use a UINavigationItem and apply it by "pushNavigationItem" on the UINavigationBar.

我创建了一个子类UINavigationBar调用StaticNavigationBar,然后我可以通过在其上放置适当的UINavigationItem来加载任何状态。感谢您的所有答案。

I created a subclass of UINavigationBar called StaticNavigationBar which I can then load with any state by putting the appropriate UINavigationItem's on it. Thanks for all your answers people.

这篇关于使用UINavigationBar而不使用UINavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆