我一直在研究这个问题一段时间,并认为我会寻求一些帮助。我有3个视图控制器:1个导航控制器,1个主控制器和1个详细视图控制器。从子视图导航视图控制器
在主视图控制器中,我有一系列按钮的子视图。但是,由于类结构,我无法直接调用self.storyboard来获取当前故事板对象。
我已经尝试了2种不同的方法,各种方式,但仍然不成功。我在下面发布了我的方法,并描述了每个细分市场中没有发生的事情和情况。总体目标是通过点击子视图中的按钮来呈现子视图控制器(详细视图),该子视图中无法直接访问父级故事板。
方法1
//Instantiate the new view controller
ProfileViewViewController *tempViewToShow = [del.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"profile"];
// Pass data into the new view controller
tempViewToShow.thisUser = self.postUser;
// Output a simple log to ensure both were created
NSLog(@"Temp User Name: %@, Profile Desc: %@", [tempViewToShow.thisUser getFullName], tempViewToShow.description);
// Using the AppDelegate for the RootViewController, present the detail view
[UIApplication.sharedApplication.delegate.window.rootViewController presentViewController:tempViewToShow animated:YES completion:NULL];
问题 这一系列的问题是,详细视图不携带导航控制器(因为它未提及),然而,这种方式仍然显示完整的视图控制器
方法2
个...
// Use the Delegate and the navigation controller to present the new view controller
[UIApplication.sharedApplication.delegate.window.rootViewController.navigationController presentViewController:tempViewToShow animated:YES completion:NULL];
问题 不显示任何内容
方法3
// Use the recommended 'pushViewController' for the navigation controller to carry over
[UIApplication.sharedApplication.delegate.window.rootViewController.navigationController pushViewController:tempViewToShow animated:NO];
问题 不显示任何内容
恩托托,我会如何做这项工作?我会修改哪些行,以及如何修改?谢谢!
你想要做什么?你想要导航栏吗? – KKRocks