简体   繁体   中英

Navigation Controller for the Main View Controller in a Utility application?

I have created a utility app that links by button to another xib called scene - I am trying to create a navigation control for that link. When the button is clicked to then have a 'back' button on my scene xib. I don't wish to have a navigation bar visible on the Main View Controller or the Flipside View Controller. I'm quite new to iOS and I have no idea how to do this?

Would it maybe just be better to have a button going back to menu on a custom HUD? I don't know if that can be done?

Thank you for any help in advance, and thank you for your time

您可以在场景xib上创建一个自定义UINavigationBar ,如果不想创建NavigationController ,则向其添加自定义后退按钮;或者,您可以将第一个视图作为NavigationController并将其推入场景视图,然后它将在作为场景的子视图上显示后退按钮,当您位于MainViewController上时,隐藏NavigationBar并仅在场景视图上显示。

For hide UINavigationBar:

[[self navigationController] setNavigationBarHidden:YES animated:YES];

And Your can crate Custom UIButton and put anywhere ( As Your requirement ). and in its method, Write code for go back to UIViewController ( previous UIVieController ).

Such like,

UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
[btnBack addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
btnBack.frame = CGRectMake(10, 10.5, 36, 39); // change it , As your wish 
[btnBack setBackgroundImage:[UIImage imageNamed:@"MMBack.png"] forState:UIControlStateNormal];
[self.view addSubview:btnBack];

// call method of UIButton

-(void)goBack:(UIButton *) Sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM