As described in the title, i would like to push a view, from a known NIB, using a button on the navigation bar. I'm working on a UINavigationController app.
I already added the right button in IB and i linked it to the method that is in the RootViewController
I have searched everywhere but I couldn't find a way to do this method...
-(IBAction)addItems:(id)sender 开发者_Go百科
{
?
}
I also tried this solution, but it isn't working either...
For example:
-(IBAction)addItems:(id)sender
{
CustomController *controller = [[CustomController alloc] initWithNibName:@"CustomController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
Where
CustomController
name of your custom controller class.@"CustomController"
name of your xib file
If you just need the view from nib file, then try this..
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"QPickOneView"
owner:self
options:nil];
UIView* myView = [ nibViews objectAtIndex: 0];
self.view = myView;
If you want to push a ViewController..Then go with the Nekto's Answer.
精彩评论