0

I am having an issue when im using navigation controller. My program is laid out where I have a start screen (not in the navigation controller) and then when you press a button it sends you to the navigationController and new view.

How can I call the navigation controller from the start screen?

liv a
  • 3,232
  • 6
  • 35
  • 76
  • Put main view(start screen) in navigation controller as root view and push new view when button press(tap). – Navnath Godse Jun 06 '13 at 06:54
  • I don't want the back option that the navigation gives by default, I want it to behave like once i clicked the button the uitableviewcontroller behaves as the main screen – liv a Jun 06 '13 at 06:56
  • Oh that is an issue!, you can disable back functionality of navigation controller but it is not good solution, Ok i will think on another idea for it, hope you will get answer from others. – Navnath Godse Jun 06 '13 at 07:02

3 Answers3

0

Pushing a view controller will only work if the view controller pushing is contained in a navigation controller. You can try to hide the navigation bar in the pushed view controller: how to hide navigationbar when i push from navigation controller?

If you still want to keep your structure, the possible solution would be to present the navigation controller with table view controller as a modal. You need to use the presentViewController:animated:completion: method in the start view controller:

[self presentViewController:theTableViewController animated:YES completion:nil];
Community
  • 1
  • 1
Valent Richie
  • 5,226
  • 1
  • 20
  • 21
  • self = UIViewController i get a compile error `No visible @interface for 'viewController' declares the selector 'pushViewController:animated` – liv a Jun 06 '13 at 11:12
  • If you want use push, you need a navigation controller, and call pushViewController from self.navigationController – Valent Richie Jun 06 '13 at 11:17
0

in AppDelegate.h class

Create a property of UINavigationController like:

@property (strong,nonatomic) UINavigationController *navigationController;

and in give it as a RootViewController in AppDelegate.m like:

self.navigationController = [[UINavigationController alloc]initWithRootViewController:self.viewController];

and give it to Window like:

self.window.rootViewController = self.navigationController;

Thats it!!! You are Done!!

Now you have navigationController at the root as well.

Cheers!!

Deepak Khiwani
  • 734
  • 1
  • 8
  • 33
  • in which function in the appDelegate.m should I write this code? also how do I call it when the button is clicked? and last but not least how do I return to the original main screen, Thank you – liv a Jun 06 '13 at 11:05
  • `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` – Deepak Khiwani Jun 06 '13 at 11:22
0

If you don't have any problem in adding first controller to UINavigationViewController then do the following to do this just from interface builer :

1) Select first view controller in storyboard. 2) From menubar select Editor -> Embed In -> Navigation Controller.

Geek
  • 8,280
  • 17
  • 73
  • 137