0

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
  • 1
    In order to push a new view controller onto the stack, your existing view must have a UINavigationController as its parent. It appears that your code may have gotten mangled when you posted it, but the relevant method is pushViewController:animated: Commented Jul 22, 2010 at 5:54

1 Answer 1

1

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];  
Sign up to request clarification or add additional context in comments.

6 Comments

I have no navigationcontroller. Can I open 2nd viewcontroller from 1st viewcontroller.
you can do : [self presentModalViewController:animated:]
I have tried with presentModalViewController. But it does not work.
Is your class a UIViewController? It should work, it always works for me
I have UIViewController in Viewbased application. I want to push another UIViewcontroller from it.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.