iPhone:在我的应用程序的所有视图中都可以有一个“信息"按钮吗? [英] iPhone: Is it possible to have an 'info'-button in all views in my app?

查看:55
本文介绍了iPhone:在我的应用程序的所有视图中都可以有一个“信息"按钮吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如标题中所述,如何实现这种功能?

As mentioned in the title, how do I implement such a functionality?

我正在使用下面的代码(在我的viewDidLoad中)来获取主视图的导航控制器上的按钮.

I am using the code below, (in my viewDidLoad), to get the button on my Navigation Controller of my main view.

UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

[infoButton addTarget:self action:@selector(viewWillAppear:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];

不确定如何在所有视图中显示它.

Not sure how I can get it displayed in all my views.

推荐答案

每个推送到导航堆栈的视图都有自己的导航栏.因此,恐怕您在创建视图时以及在将该视图推入导航堆栈之前必须将其添加到每个导航栏.

Each view pushed to the navigation stack has an own navigation bar. So I afraid you have to add this button to each navigation bar, when you create a view and before you push this view to the navigation stack.

这篇关于iPhone:在我的应用程序的所有视图中都可以有一个“信息"按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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