Modal unwind segue无法使用Apple的MutlipleDetailViews(Modal unwind segue not working with apple's Mut

编程入门 行业动态 更新时间:2024-10-26 04:32:23
Modal unwind segue无法使用Apple的MutlipleDetailViews(Modal unwind segue not working with apple's MutlipleDetailViews)

我正在使用Apple的多个详细视图示例来设置一个带有主控制器的iPad拆分视图控制器应用程序 - 一个选项卡视图,每个选项卡包含一个表视图...但是在每个选项卡视图中我还想为用户提供选项单击调用模式segue的添加按钮以添加CoreData对象的新实例,该实例为该选项卡下的表视图提供数据。 我遇到的唯一问题是,当我将ViewController中的unwind segue链接到modConally时,会调用unwind方法,但不会从屏幕中删除ViewController。

我的第一个想法是尝试打电话

[self.navigationController dismissViewControllerAnimated:YES completion:^{}];

在unwind方法中,有效 - 但是当您再次单击添加按钮时,会出现EXC_BAD_ACCESS(code = 1,adress == ...)错误,这很奇怪,因为应用程序不应该尝试访问任何可能已经被释放的对象,只是从故事板中初始化一个新的模态视图控制器实例?

任何帮助将不胜感激!

I am using Apple's multiple detail views example to set up an iPad split view controller app with a master controller - a tab view each tab containing a table view... However in each of these tab views I also want to give the user the option to click an add button which calls a modal segue to add a new instance of the CoreData object which is providing data for the table view under that tab. The only problem I'm having is that when I link up the unwind segue from the ViewController which is segued to modally the unwind method gets called, but doesn't remove the ViewController from the screen.

My first idea was to try calling

[self.navigationController dismissViewControllerAnimated:YES completion:^{}];

Within the unwind method, which works - however when you next click the add button again you get a EXC_BAD_ACCESS (code = 1, adress==...) error, which is strange as nothing surely the app shouldn't be trying to access any objects which may have been dealloc'd but simply init'ing a new instance of the modal view controller from the Storyboard?

Any help would be greatly appreciated!

最满意答案

我有同样的问题...如果它是一个模态segue你先调用,那么你可以尝试调用dismissViewControllerAnimated:来自self,而不是来自self.navigationController:

[self dismissViewControllerAnimated:YES completion:nil];

I had the same issue ... If it is a modal segue you were calling first, then you could maybe try to call dismissViewControllerAnimated: from self, not from self.navigationController :

[self dismissViewControllerAnimated:YES completion:nil];

更多推荐

本文发布于:2023-07-16 09:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126820.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:segue   unwind   Modal   Apple   apple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!