开发者

loading a Navigation Controller from a button

I Have a view with a button. I want to press the button and that a Navigation Controller will appear, and in it there will be a back button that will bring me to the original view.

this is how i load the Navigation Controller:

-(IBAction) viewButtonPressed:(id) sender

{

[self.view addSubview:navController.view];

[self.view bringSubviewToFront:navController.view];

}

in the rootController of the NAvagtion Controller I tried this, but it does no开发者_如何学Got work (the back button does not even appear):

@implementation rootViewController

- (void)viewDidLoad {

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(customGoBack:)];

}


navigationController is the stack of viewControllers. You didn't push any controller except root to this stack, so there is no back button in the navigationBar. You can create separate controller to push it into the navigationController's stack. If you son't want to see navigationBar on your first controller's view, just send - (void)setNavigationBarHidden:YES animated:NO to your instance of UINavigationController.


Use this code,

YourViewController *yvController= [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:yvController animated:NO];

Its the simplest way to navigate on different views.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜