[英]how should I keep track of a detailViewController from a changing masterViewController?
Update - I think I figured it out but please read my question if you'd like and check that my solution (in answers) is correct, thank you. 更新 -我想我已经解决了,但是请阅读我的问题,并检查我的解决方案(在答案中)是否正确,谢谢。
I'm new to the splitViewController and I'm having a hard time understanding how I should pop the detail view controller when the master is popped. 我是splitViewController的新手,我很难理解当弹出master时应该如何弹出局部视图控制器。
This may be hard for me to explain but I will try my best, here is a screenshot to understand my storyboard: 这可能让我难以解释,但我会尽力而为,以下是用于了解故事板的屏幕截图:
The MasterView is a NavigationController that has RootViewController of a TableView, when a user selects a cell the masterView pushes the next tableview and the detail is changed programmatically like so: MasterView是一个NavigationController,具有TableView的RootViewController,当用户选择一个单元格时,masterView会推送下一个TableView,并以编程方式更改详细信息,如下所示:
In the initial root: 在初始根目录中:
detailViewController = (CCGViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
When a cell is clicked in root 在根中单击单元格时
[detailViewController performSegueWithIdentifier:@"replaceSearchWithSponsor" sender:self];
This is working to drill down but when I pop the Master View navigation controller I'd like to set up a good way to pop the detail views in their navigation stacks. 这是为了进行深入研究,但是当我弹出Master View导航控制器时,我想建立一个很好的方法来在其导航堆栈中弹出详细视图。
Any suggestions would be greatly appreciated. 任何建议将不胜感激。
thank you. 谢谢。
I just subclassed UINavigationController and when I popped MasterNavigationController I popped the Detail as well. 我只是继承了UINavigationController,当我弹出MasterNavigationController时,我也弹出了Detail。 This seems to work for me, if you see any potential issues let me know:
如果您发现任何潜在的问题,请告诉我,这似乎对我有用:
in .h : 在.h中:
@interface CCGPopMasterNavigationController : UINavigationController
@end
in .m 在.m中
@interface CCGPopMasterNavigationController ()
@end
@implementation CCGPopMasterNavigationController
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
[[[[self.splitViewController.viewControllers lastObject] topViewController]navigationController
] popViewControllerAnimated:animated];
return [super popViewControllerAnimated:animated];
}
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.