![](/img/trans.png)
[英]UINavigationController toolbar buttons not animating when pressed
[英]UINavigationController Toolbar Buttons
我有一个UINavigationController我已经设置为我的窗口的rootViewController。 在NIB文件中,我已将其设置为具有“工具栏”的“底栏”。 在Interface Builder中,我添加了一个UIBarButtonItem。 这一切都很好,我可以处理按钮单击罚款。 当我点击其中一个按钮时,我将一个新视图推送到ViewController上,这也很好用。 一个问题,我的按钮在加载视图时消失。 现在在后续视图中我可以将底栏设置为工具栏,我在Interface Builder中看到它,但我无法添加任何按钮。
我知道我要么错过了一些明显的东西,要么想错了但是如何将UIBarButtonItems添加到推送到导航控制器的后续视图中? 我说的是底部的栏,而不是顶部的导航栏。
有任何想法吗?
UIViewController上的toolbarItems属性是您感兴趣的。您可以以编程方式创建UIBarButtonItems并将它们添加到viewDidLoad中的新toolBarItems数组中。
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem* editButton = [[[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(editAction)] autorelease];
[self setToolbarItems:[NSArray arrayWithObject:editButton]];
}
这对我来说效果更好:
[[self navigationItem] setLeftBarButtonItem:homeButton];
您可以在右侧执行相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.