irco
irco

Reputation: 981

Bar Button on navigation based app

I want to add a Bar button to the Navigation bar on a Navigation based app, the bar however is on the MainWindow and has no code behind so I Can't connect it to an IBAction.

how do i go about connecting it to an action ?

Upvotes: 1

Views: 566

Answers (1)

Kennzo
Kennzo

Reputation: 437

You can add the button to the navigation bar programmatically like this and also connect it up to an action with the init code:

    UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:<UIBarButtonStyle that you want> target:self action:@selector(<some_action>:)];
    self.navigationItem.rightBarButtonItem = button;
    [button release];

Upvotes: 2

Related Questions