简体   繁体   English

我应该如何从更改的masterViewController跟踪detailViewController?

[英]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.

相关问题 无法从MasterViewController访问DetailViewController - Unable to access DetailViewController from MasterViewController 在SplitViewController中从DetailViewController隐藏MasterViewController - Hide MasterViewController from DetailViewController in a SplitViewController 如何从detailViewController填充数组并返回iOS中的masterViewController? - How to populate an array from detailViewController and return to masterViewController in iOS? 使用prepareForSegue显示从MasterViewController到DetailViewController的字符串 - Displaying a string from MasterViewController to DetailViewController using prepareForSegue 在UISplitViewController应用程序中从DetailViewController获取MasterViewController - getting the MasterViewController from the DetailViewController in a UISplitViewController app 将数据从detailViewController向后传递到masterViewController - Pass data backward from detailViewController to masterViewController MasterViewController更新时如何刷新DetailViewController - How to refresh DetailViewController when MasterViewController is updated ISplitViewController:DetailViewController可以从MasterVIewController加载数据而不需要回传吗? - ISplitViewController: Can DetailViewController load data from MasterVIewController without segueing back? 从MasterViewController在DetailViewController中设置detailItem时出现奇怪的错误 - Weird Error when setting detailItem in DetailViewController from MasterViewController 弹出MasterViewcontroller时推送DetailViewController - push DetailViewController when popping MasterViewcontroller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM