0

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

2 Answers 2

1

you could create a custom UINavigationBar on your scene xib, and add the custom back button to it if you don't want to create NavigationController , alternate would be that you could just make your first view as NavigationController and push the Scene view over it and it will brings the back button on the child view which is scene, keep your navigationBar hidden when you are on MainViewController and show only on scene view.

5
  • you have UINavigationBar GUI objects, just add to your scene view and connect to its outlet and add the custom button on it and register the event for the button in your code. there are number of tutorials on internet if you don't know how to do it.
    – nsgulliver
    Mar 4, 2013 at 20:06
  • boldalternate would be that you could just make your first view as NavigationController and push the Scene view over it and it will brings the back button on the child view which is scene, keep your navigationBar hidden when you are on MainViewController and show only on scene view.**bold** This is what I did - and now I'm having trouble - I have hidden the navigation bar on the main view and on first launch it looks fine but as soon as the second view is popped off the stack there is an empty navigation bar on the main view.
    – user1992686
    Mar 4, 2013 at 20:57
  • you should hide the navigationBar when you come back from the second view, and only show it when you are on secondview, [[self navigationController] setNavigationBarHidden:YES animated:YES]; and make the navigationbar translucent so that it will not reserve place while hidden self.navController.navigationBar.translucent = YES;
    – nsgulliver
    Mar 4, 2013 at 21:00
  • you should hide the navigationBar in viewWillAppear of the main Controller and show the navigationBar in viewWillAppear of the second view, you might be hiding only in viewDidLoad of first controller
    – nsgulliver
    Mar 4, 2013 at 21:05
0

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];
}
2
  • When I hide the navigation bar and then click 'back' the bar then appears on my mainViewController, do you know how to fix this?
    – user1992686
    Mar 4, 2013 at 19:00
  • @Caroline- please put code in here(comment) of how can u go to another view controller
    – iPatel
    Mar 5, 2013 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.