swift创建unwind 过渡(unwind segue)

来源:互联网 发布:java 进程注入 编辑:程序博客网 时间:2024/05/16 19:07

转载:http://blog.csdn.net/ufo2744/article/details/44757031

有很多朋友和我一样,在swift中创建unwind过渡时遇到了一些困难,但是在object-c中没有问题,因为apple官网的教程中详细讲解啦。

https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOSCh/SecondTutorial.html#//apple_ref/
doc/uid/TP40012668-CH8-SW1

通过对比我们可以发现,其实之所以遇上困难就是这个函数无法翻译到swift。

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

但是分析一下我们可以知道,IBAction是函数的返回类型,UIStoryboardSegue*是参数类型,而segue是参数。而对应到swfit我们似乎可以这样写:

func unwindToList(segue:UIStoryboardSegue)->IBAction {}

从语法上我们应该像上面这样子写,但是事实上,因为swift认为IBAction是动作事件标识,所以我们应该写成:

@IBActionfunc unwindToList(segue:UIStoryboardSegue) {}
0 0
原创粉丝点击