How to push UIViewController
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
}
开发者_运维技巧
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];
精彩评论