导航栏上的按钮无法加载 [英] buttons on navigation bar not loading
本文介绍了导航栏上的按钮无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在导航栏上添加按钮,但它没有加载到吧。请帮助。以下是我的代码。请告诉我我哪里出错了。我使用的是景观
i want to add buttons on navigation bar but its not loading on bar.Please help.Following is my code.please tell me where i am going wrong.The view i am using is landscape
- (void)viewDidLoad {
[super viewDidLoad];
CGRect rect = CGRectMake(0.0, 0.0, 480.0, 32.0);
navBar = [[UINavigationBar alloc] initWithFrame:rect];
navBar.items = self.navigationController.navigationBar.items;
navBar.delegate = self;
//[navBar release];
navBar.tintColor =[UIColor blackColor]
UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]initWithTitle:@"Photo" style:UIBarButtonItemStyleBordered target:self action:@selector(takePhoto)];
UIBarButtonItem * backButton = [[UIBarButtonItem alloc]initWithTitle:@"Camera List" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel:)];
self.navigationItem.rightBarButtonItem = rightButton;
self.navigationItem.leftBarButtonItem = backButton;
//navBar.topItem.rightBarButtonItem = rightButton;
// navBar.topItem.leftBarButtonItem = backButton;
[self.view addSubview:navBar];
[backButton release];
}
推荐答案
试试这个
(void)viewDidLoad {
[super viewDidLoad];
CGRect rect = CGRectMake(0.0, 0.0, 480.0, 32.0);
navBar = [[UINavigationBar alloc] initWithFrame:rect];
navBar.items = self.navigationController.navigationBar.items;
navBar.delegate = self;
UINavigationItem *navigationItem = [UINavigationItem alloc];
[navBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];
UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]initWithTitle:@"Photo" style:UIBarButtonItemStyleBordered target:self action:@selector(takePhoto)];
UIBarButtonItem * backButton = [[UIBarButtonItem alloc]initWithTitle:@"Camera List" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel:)];
self.navigationItem.rightBarButtonItem = rightButton;
self.navigationItem.leftBarButtonItem = backButton;
[self.view addSubview:navBar];
[backButton release];
[rightButton release];
}
这篇关于导航栏上的按钮无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文