在查看了每一个stackoverflow上关于这个问题的解决方案之后,对我来说仍然非常令人沮丧地无法工作。
//UIBarButtonItem declaration
UIBarButtonItem* button1 = [[UIBarButtonItem alloc] initWithTitle:@"Button Text"
style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)];
//method 1
[self setToolbarItems:[NSArray arrayWithObjects: button1, nil] animated:YES];
//method 2
[self.navigationController.toolbar setItems:[NSArray arrayWithObject:button1]];
//method 3
self.navigationController.toolbarItems = [NSArray arrayWithObject:button1];
//displaying toolbar
[self.navigationController setToolbarHidden:NO];
以上所有方法都不能在工具栏上显示按钮 - 我只得到一个空白的工具栏。我是否忽略了什么明显的东西?
self.navigationController.toolbar
是空的还是非空的? - Raptor