如何向UIBarButtonItem
添加通用右/左UINavigationController
?我正在尝试使用相同的左右导航栏按钮为所有UIViewController
制作基于导航的应用
谢谢
答案 0 :(得分:2)
创建一个基础UIViewController
@interface BaseController : UIViewController
{
}
@end
@implementation BaseController
- (id)init
{
//set the universal barbuttonitem
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:yourView] autorelease];
}
@end
然后你的所有viewController应该从BaseController扩展
已经完成了
答案 1 :(得分:0)
You can add the rightbarButtonItem in this way :-
UIBarButtonItem *btnName= [[[UIBarButtonItem alloc initWithTitle:@"btnTitle" style:UIBarButtonItemStyleBordered target:self action:@selector(btnAction)]autorelease];
self.navigationItem.rightBarButtonItem = btnName;