我正在为我的应用程序使用模型“Master-detail application”,并希望设置不同的初始视图。可能吗?我想显示带有菜单按钮的UIViewController,其中一个按钮应该加载上一个原始初始视图的导航控制器。
当我将storyBoards UI中的初始视图更改为ViewController并将按钮链接到NavigationController时,应用程序会崩溃。
做什么是正确的?
感谢您的时间!
答案 0 :(得分:0)
将此代码包含在AppDelegate中:
- (void)tellDelegateToFlip{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
masterViewController.managedObjectContext = self.managedObjectContext;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
[UIView setAnimationTransition:UIViewAnimationOptionTransitionFlipFromLeft forView:self.window cache:YES];
[self.navigationController pushViewController:masterViewController animated:YES];
[UIView commitAnimations];
}
这个方法以初始视图调用主视图:
-(IBAction)flipToMaster:(id)sender{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate tellDelegateToFlip];
}
你已经完成了!