问题描述
我想在我的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并在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!