如何在界面生成器中添加条形按钮项? [英] How to add a bar button item in interface builder?

查看:57
本文介绍了如何在界面生成器中添加条形按钮项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的是iPhone开发的新手,我需要帮助设置我的观点.

I am really new to iPhone development and I need help setting up my views.

我有一个名为FirstViewController.xib的视图和该视图的控制器类.

I have a view that is named FirstViewController.xib and a controller class for this view.

在我的MainWindox.xib中,我设置了具有moveToNextView功能的根控制器,该功能连接到选项栏按钮项.

In my MainWindox.xib I have setup a root controller with a moveToNextView function that is connected to the options bar button item.

因此,当我单击此项目时,当前视图将切换到第一个视图,并且可以切换回原来的视图.到目前为止,一切正常.

So when I click on this item the current view switches to the first view and I am able to swticht back. That works fine so far.

MainWindow.xib中位于屏幕顶部的导航栏也显示在第一个视图中.但是当我打开FirstViewController.xib时,没有定义任何导航栏(但是在build&运行时会显示出来).

The navigation bar at the top of the screen from the MainWindow.xib is displayed in the first view, too. But when I open FirstViewController.xib there isn't any navigation bar defined (but on build&run it is displayed).

这对我来说是个问题,因为我想在第一个视图中添加一个保存栏项.我该怎么解决?

This is a problem for me because I want to add a save bar item to the first view. How do I solve that?

推荐答案

您必须通过代码来完成.添加到您的FirstViewController类viewDidLoad方法:

You have to do it from code. Add to your FirstViewController class viewDidLoad method:

  UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(doSave:)];
  self.navigationItem.rightBarButtonItem = anotherButton;
  [anotherButton release];

这篇关于如何在界面生成器中添加条形按钮项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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