Вы можете сделать это с помощью метода viewDidLoad контроллера представления:
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem* infoButton = [[UIBarButtonItem alloc] initWithTitle:@"Info"
style:UIBarButtonItemStylePlain
target:self
action:@selector(infoButtonSelected:)];
self.navigationItem.rightBarButtonItem = infoButton;
[infoButton release];
}
В примере, когда нажимается кнопка, у вас также должен быть метод:
- (void)infoButtonSelected:(id)sender {
NSLog(@"button tapped");
// whatever needs to happen when button is tapped
}