I'd like to display a ModalViewController from a bar button in the MainWindow.xib file. How would I do this? The basic code I'm looking to use is this:
-(IBAction)add {
myCustomViewController *add = [[myCustomViewController alloc] initWithNibName:@"myCustomViewController" bundle:nil];
[self presentModalViewController:add animated:YES];
[add release];
}
But where do I put it?
EDIT: I figured it out, in my navigation controller i put the following code in viewDidLoad:
UIBarButtonItem *addbutton = self.navigationItem.leftBarButtonItem;
[addbutton setTarget:self];
[addbutton setAction:@selector(add)];
and changed the function to:
- (void)add {
myCustomViewController *add = [[myCustomViewController alloc] initWithNibName:@"myCustomViewController" bundle:nil];
[self presentModalViewController:add animated:YES];
[add release];
}
Thanks for your help, Parth!