I have a working project, one of the screen is for example ViewController 1 – tableView. i am trying to pass data and navigate to ViewController 2 after selecting a row in ViewController 1. I added this code:
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
dvController.selectedItem = selectedItem;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
But its not passing to ViewController 2. I think the problem is with navigatorController.
Where should I add it? to xib file of ViewController 1? or to the mainAppDelegate – I dont want to touch it because its already working with its settings…
I declared UINavigationController *navigationController in my appDelegate
What should I check?
After some changes to to code (thanks to @Vakul Saini)
appDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.View1 = [[startSearching alloc] initWithNibName:@"StartSearching" bundle:nil];
self.currentNC = [[UINavigationController alloc] initWithRootViewController:self.View1];
//this line start the startSearching at the begining and its passing to //secondViewController
self.window.rootViewController = self.currentNC;
// but with this line its start from the original start page but the transfer of views //doesn’t wroks
[self.window setRootViewController: self.viewController];
appDelegate.h
@property (strong, nonatomic) startSearching *View1;
@property (strong, nonatomic) UINavigationController *currentNC;
startSearching.m
detailCon *detailCo =[[detailCon alloc] initWithNibName: @"detailView" bundle: [NSBundle mainBundle]];
[detailCon release];
UINavigation *currentNC1 = [[AppDelagate sharedInstance] currentNC];
[currentVC1 pushViewController:detailCo animated:YES];
Check you have a
UINavigationControllerin yourAppdelegateor not. You need to make your approotViewControllerisUINavigationControllerAdd your
UINavigationControllerinappdelegateAppdelegate.h file
Appdelegate.m file
Where
ViewControlleris your firstView of app.