I've seen many of applications that have an info button (the letter "i" with a circle around it) on the uinavigationbar. How do I add this type of button?
A:
You should be able to add an "Info Light" type button to the navigationItem of the view controller that the UINavigationController is currently displaying. Something like this could go in your view controller code:
- (void) viewDidLoad {
UIButton * info = [UIButton buttonWithType:UIButtonTypeInfoLight];
// set your button's target and selector for whatever action here.
self.navigationItem.rightBarButtonItem.customView = info;
}
Kevlar
2009-09-21 18:58:48
Kevlar, Please modify your answer.. buttonType is a readonly property. You can't set it!
Prakash
2010-01-15 14:12:39
my bad, i was going from memory and didnt have the docs in front of me; changing now.
Kevlar
2010-01-20 20:30:56
+9
A:
The previous answer was close, didn't quite compile. Here's what you really want:
// Info button
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(showInfoView:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
Blake Watters
2009-09-22 17:05:46