【发布时间】:2017-04-27 09:07:22
【问题描述】:
我一直在研究这个问题一段时间,并认为我会寻求一些帮助。我有 3 个视图控制器:1 个导航控制器、1 个主控制器和 1 个详细视图控制器。
在主视图控制器中,我有一系列带有按钮的子视图。但是,由于类结构的原因,我无法直接调用 self.storyboard 来获取当前的故事板对象。
我尝试了 2 种不同的方法,多种方式,但仍然不成功。我在下面发布了我的方法,并描述了每个部分中发生了什么和没有发生什么。总体目标是通过点击子视图中的按钮来呈现子视图控制器(详细视图),该子视图无法直接访问父情节提要。
方法一
//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];
问题 这个系列的问题是细节视图没有携带导航控制器(因为没有提到),但是这种方式仍然显示完整的视图控制器
方法二
...
// 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];
问题 不显示任何内容
En toto,我将如何进行这项工作?我将修改哪些行以及如何修改?谢谢!
【问题讨论】:
-
你想做什么?你想要导航栏吗?
标签: ios objective-c