UIBarButton不会显示在Tab Controller中的Table View上
noob关于ios开发的问题。
在以前的项目中,我有一个UITableViewController,我在viewDidLoad方法中添加一个button,如下所示:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(addMeasurement:)]; self.navigationItem.rightBarButtonItem = button; [button release];
这很好。
我现在有另一个应用程序,我试图做同样的事情,除了现在我有一个UITabBarControllerDelegate在顶部(默认伴随着“标签栏应用程序”),其第一个视图是UITableViewController。
第一视图没有笔尖,因为它只是一张桌子。 我试图用相同的代码做同样的事情,试图在viewDidLoad方法中添加一个button,但它不工作。
所以在第一个ViewController(这是一个UITableViewController)我将上面的代码添加到viewDidLoad方法,没有成功。
它显示的是表中的数据,但是(来自managedObjectContext)。 我也试着把代码放在firstViewController的“initWithStyle”方法中,但是这也不起作用。
有任何想法吗? 显然我不是理解的东西。
谢谢!
做这个。
-
创build选项卡栏控制器并将其设置为您的rootController。
//You will not have three tabs and you need three view controllers//
-
将您的第一视图控制器设置为导航视图控制器。
// You will now have the Navigation bar at the top//
-
创build一个新的文件,它是UITableViewController的子类。
// set this as your delegate and datasource for your table view controller methods// // pull a table view controller inside the Navigation View Controller as mentioned in (2) & you will have a tableview and navigation view in FirstViewController. Similarly work with the other two tabs
如果你有任何疑问, 请看这个教程如何做所有这些。
如果我没有错,你需要有一个UINavigationController中的UITableViewController为了显示UIBarButtonItems。