Never_be
Never_be

Reputation: 849

How to push to new View with programatically created UINavigationController?

I try many sings from this site but not get result. Now I open new View like this:

//(I call this code from View called MainReportView)
InfoController *info = (InfoController *)[self.storyboard instantiateViewControllerWithIdentifier:@"InfoController"];

info.login = login;
info.password = password;

[self presentViewController:info animated:YES completion:nil];

all working good, but I want previous View be in the same state when I return to him. People say use NavigationController and push to him but this is a problem. I add NavigationController to storyboard (to MainReportView) and try change code to:

 [self pushViewController:info animated:YES completion:nil];

but nothing happens, view not open, please help how I can programatically in this code add NavigationController and open my InfoController with push ? Thanks ! (I use Xcode 5 and iOS 7 + Storyboard)

Solution - for iOS7 use prepareForSegue, and this tutorial

Upvotes: 1

Views: 1159

Answers (2)

Mayank Jain
Mayank Jain

Reputation: 5754

enter image description here

UIStoryboard *MainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                         bundle: nil];
InfoController *info=[MainStoryboard instantiateViewControllerWithIdentifier:@"InfoController"];
[self.navigationController pushViewController:info animated:YES completion:nil]; 

full step by step guide

Upvotes: 5

Khawar Ali
Khawar Ali

Reputation: 3506

Push the new view controller in the navigation controller like this:

InfoController *info = (InfoController *)[self.storyboard instantiateViewControllerWithIdentifier:@"InfoController"];
[self.navigationController pushViewController:info animated:YES completion:nil]; 

Upvotes: 1

Related Questions