Я не уверен, что мне здесь не хватает. У меня есть пользовательский UINavigationController
, и я пытаюсь добавить постоянный UIBarButtonItem
в панель.
-(void)viewDidLoad
{
self.navigationBar.barStyle = UIBarStyleBlack;
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Nope..."
style:UIBarButtonItemStyleBordered
target:self
action:@selector(goBack:)];
self.navigationItem.leftBarButtonItem =bbi;
[bbi release];
}
-(void)goBack:(id)sender
{
NSLog(@"go back now");
}
что мне здесь не хватает? - Кстати, я не хочу / не буду использовать IB.
UPDATE:
На данный момент это самое близкое, что я могу получить:
-(void)viewDidLoad
{
self.navigationBar.barStyle = UIBarStyleBlack;
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];
navBar.barStyle = UIBarStyleBlack;
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"Currently Playing..."];
[navBar pushNavigationItem:navItem animated:NO];
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack:)];
navItem.rightBarButtonItem = editButton;
[self.view addSubview:navBar];
[editButton release];
[navItem release];
[navBar release];
[super viewDidLoad];
}
Это ужасно, я должен добавить всю панель навигации к UINavigationController
, который уже имеет панель навигации .... если я пытаюсь использовать существующую, я получаю эту ошибку:
'NSInternalInconsistencyException', reason: 'Cannot call pushNavigationItem:animated: directly on a UINavigationBar managed by a controller.'
.... действительно ???