Я пытаюсь нажать UIViewController на контроллер навигации, а затем добавить UIBarButtonItem в панель навигации, чтобы я мог использовать его для отображения таймера обратного отсчета.Добавить UIBarButtonItem в UIViewController, нажатый на контроллер UINavigation
UINavigationController *navController = [[Session sharedInstance] getNavigationController];
GamePlayViewController *gameController = [[GamePlayViewController alloc] initWithNibName:@"GamePlayViewController" bundle:nil ];
UIBarButtonItem *timerBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
gameController.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:timerBtn, nil];
[navController pushViewController:gameController animated:YES];
Когда я использую код выше его, он не работает. Я также попытался сделать это из метода ViewDidload в самом контроллере, но не в кости. Я даже пытался использовать rightBarButtonItem, но получаю сообщение об ошибке с указанием
"to uncaught exception 'NSInvalidArgumentException', reason: 'Fixed and flexible space items not allowed as individual navigation bar button item. Please use the leftBarButtonItems (that's plural) property.'
*** First throw call stack:"
UIBarButtonItem *timerBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
self.navigationItem.rightBarButtonItem = timerBtn;
Работала Спасибо !! –