tags:

views:

28

answers:

1

I have UIViewController in Viewbased application. I want to push another UIViewcontroller from it.

-(IBAction) Myfunction
{

 MedicineSearchSystem *medicineSearchSystem = [[MedicineSearchSystem alloc]        initWithNibName:@"MedicineSearchSystem" bundle:nil];

 [self.parentViewController:medicineSearchSystem animated:YES]; // Crash here

}
+1  A: 

As warrenm already told you, first check if your viewController has a navigationController by calling something like : NSLog(@"%@", self.navigationController) then you can push using:

[self.navigationController pushViewController:medicineSearchSystem animated:YES];

    self.mainItemListViewController = [[[NCItemsViewController alloc] init] autorelease];

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

[window addSubview:[self.navigationController view]];
[window makeKeyAndVisible];  
vodkhang
I have no navigationcontroller. Can I open 2nd viewcontroller from 1st viewcontroller.
Dhaval
you can do : [self presentModalViewController:animated:]
vodkhang
I have tried with presentModalViewController. But it does not work.
Dhaval
Is your class a UIViewController? It should work, it always works for me
vodkhang
I have UIViewController in Viewbased application. I want to push another UIViewcontroller from it.
Dhaval
So, the present method works right. If you want to push, you have to init the navigationController and set the firstViewController to be the root View Controller. then you can push
vodkhang
look at the answer again. I editted it
vodkhang