ios - 放松 segue 不工作

标签 ios objective-c segue

我目前正在学习来自 Apple's Start Developing iOS Apps 的教程.

在教程: Storyboard页面(上面的链接)上,我被告知要为两个 View 创建自定义类。为简单起见,我将它们称为 TableView (有一个表)和添加 View (有一个用于向表中添加项目的文本字段)。

Table View 有一个链接打开 Add View 的按钮,Add View 的导航栏上有两个按钮:Cancel 和 Done。

我被告知在添加 View 的 .m 文件中编写一个空方法 unwindToList:

- (IBAction)unwindToList:(UIStoryboardSegue *)segue
{

}

然后我被告知将“取消”和“完成”按钮都链接到 Scene Dock 中的“退出”项(见底部图像),并选择方法 unwindToList。因此,正如教程中所引述的那样,这就是应该发生的情况:

Now, run your app. At launch, you see a table view—but there’s no data in it. You can click the Add button and navigate to [the Add View] from [the Table View]. You can click the Cancel and Done buttons to navigate back to [the Table View]."

但是,当我单击“取消”或“完成”时,什么也没有发生。我确定两者都有关联。

提前致谢!

Tutorial Image

最佳答案

如果您仔细阅读本教程,您会发现展开方法需要在您展开到UIViewController中 - 来自教程 -

An unwind segue is created by adding an action method to the destination view controller (the view controller you want to unwind to).

...

Because you want to unwind back to XYZToDoListTableViewController, you need to add an action method with this format to the XYZToDoListTableViewController interface and implementation.

因此,您应该在 TableView Controller 中创建您的 unwindToList 方法,而不是在添加 View Controller 中。

关于ios - 放松 segue 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23721818/

相关文章:

objective-c - 通过指针枚举 NSString 字符

ios - 程序化嵌入转场

iOS - UIViewController 中的依赖注入(inject)

ios - 提取 NSString 中两个子串之间的部分

ios - JASidePanels 修复右面板边界

iphone - 将整数转换为日期字符串

ios - 点击后退按钮后,通过 segue 的数据丢失

ios - 由于 cocoa pod 中的内部保护错误快速类功能而无法访问

ios - becomeFirstResponder 非常慢

ios - UI View 框架在 UItableview ios 中不刷新