如何添加后退按钮编程UINavigationBar的? [英] How do I add back button to UINavigationBar programmatically?

查看:142
本文介绍了如何添加后退按钮编程UINavigationBar的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UINavigationController,当我把我的观点之一,我的顶端有一个UINavigationBar的,我提出了伊娃和连接它。现在,我需要的是那个按钮就是喜欢在酒吧的左半边广场和半箭头。我将如何做到这一点编程?所有我需要做的是说回来,被点击时做我的背动作。我会怎么做呢?

I have a UINavigationController and when I push one of my views, I have a UINavigationBar on top that I made an ivar for and connected it. Now what I need is that button that is like half square and half arrow on the left of the bar. How would I do this programmatically? All I need it to do is say back and do my back action when it is clicked. How would I do this?

谢谢!

推荐答案

如果您使用的是UINaviationController,那么你推到它的每个视图控制器不需要它在笔尖或$ C成立了自己的UINavigationBar的对象$ C。你得到它和'自由',当你推一个视图控制器到导航控制器的堆栈后退按钮。

If you're using a UINaviationController, then each view controller that you push onto it does not need it's own UINavigationBar object set up in the nib or in code. You get it and a back button 'for free' when you push a view controller onto a navigation controller's stack.

所以从您的推视图控制器删除UINavigationBar的。它实际上可以阻止导航控制器的导航栏。

So remove the UINavigationBar from your pushed view controller. It could actually be blocking the navigation controller's navigation bar.

如果您使用的是笔尖设置您的视图控制器,你可以添加一个'模拟元素,让你在笔尖假的导航栏,以帮助布置您的用户界面元素。

If you're using a nib to set up your view controller, you can add a 'simulated element' so that you have a fake navigation bar in the nib to help lay out your UI elements.

编辑:X轴code 4,他们现在被称为模拟指标。设置顶酒吧在你的笔尖,模拟导航栏。

in Xcode 4, they're now called 'Simulated Metrics'. Set the 'Top Bar' to simulate a navigation bar in your nib.

这篇关于如何添加后退按钮编程UINavigationBar的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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