2

如何将通用右/左添加UIBarButtonItem到 a UINavigationController?我正在尝试使用相同的左右导航栏按钮制作一个基于导航的应用程序,UIViewController 谢谢

4

2 回答 2

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 扩展

完成了

于 2012-05-09T09:32:44.727 回答
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; 
于 2012-05-09T09:56:25.063 回答