2012-07-24 63 views
0

我正在开发一个基于TabBar的应用程序,当在第一个视图中选中一个单元格时出现一个UIViewController。我想添加一个UIToolBar,其中包含由选定单元格的segue给出的一些信息(在项目中)。我已经尝试过的代码波纹管(类似的问题,发现),但它不工作:添加一个新的UIToolbar到UIViewController

if (self) { 
    NSArray* toolbarItems = [NSArray arrayWithObjects: 
          [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
                      target:self 
                      action:@selector(addStuff:)], 
          [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch 
                      target:self 
                      action:@selector(searchStuff:)], 
          nil]; 
    [self setToolbarItems:toolbarItems]; 
    [self.navigationController setToolbarHidden:NO animated: YES]; 

} 
return self; 

有谁知道另一种方式来过一个由导航控制器推断添加新UIToolBar?

回答

0

我通过添加一个IBOutlet UIToolBar并将其定义为视图的工具栏来解决了我的问题。 theToolBar = [[self navigationController] toolbar];

相关问题