开发者

Push a view from a nib file using a right navigation bar button

开发者 https://www.devze.com 2023-04-08 06:47 出处:网络
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.

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

  1. CustomController name of your custom controller class.
  2. @"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.

0

精彩评论

暂无评论...
验证码 换一张
取 消