Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put an "info" button on the iPhone nav bar?

Tags:

iphone

I want to put an 'i' button on the nav bar (on all the screens in which the nav bar appears). Touching on that button should bring up a view (perhaps modal) in which I can have controls. How do I put the button on the nav bar, and what how will I execute the call back?

like image 503
PrinceOfMaine Avatar asked Aug 20 '09 18:08

PrinceOfMaine


1 Answers

Info Button Code:

UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
    [infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
    [self.navigationItem setLeftBarButtonItem:modalButton animated:YES];
    [modalButton release];

The code above calls method -(void)infoButtonAction. Add this to all of your ViewControllers or just create one .nib and use that for all of your views.

like image 146
Jordan Avatar answered Sep 30 '22 19:09

Jordan