在阅读了iOS 8自定义动画转场上手指南后,刚开始不理解,后来慢慢消化了,现在总结如下:

1. 自定义Segue关键在于继承UIStoryboardSegue并重写perform方法

2. 动画可以在转场之间的任何方法中添加(Segue的perform方法、prepareSegue、UnwindSegue对应的IBAction方法),但最好统一一下,放在perform中去

3. UnwindSegue关键要在返回的目标VC中定义IBAction,然后才能在Storyboard中通过拖拽并选择IBAction来创建UnwindSegue

4. 创建Segue的时候一定记得要写SegueId(Storyboard中选中Segue后右侧属性列表中有),代码中需要通过id来判断segue

5. -(UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier 一定要在转场目标VC中重写此方法,而不是源VC中

6. 转场动画结束后,记得调用

self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)

或者

self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)

来最终完成segue工作。

7. Segue转场流程:[A performSegueWithIdentifier:sender:] --> [B init]  [B awakeFromNib]--> Find segue defined in storyboard by id. --> [A prepareForSegue:sender:](传递数据)  --> [customSegue perform] -->  [B viewDidload]

UnwindSegue转场流程:[B performSegueWithIdentifier:sender: --> [A segueForUnwindingToViewController:fromViewController:identifier:](Find unwind segue from destination VC's segueForUnwindingToViewController selector.) --> [B prepareForSegue:sender:](传递数据)  --> [A -(IBAction)returnFromSegue:(UIStoryboardSegue *)sender] (IBAction relative by unwind segue id which defined in storyboard)

搞定,希望能帮助到有需要的猿!

最新文章

  1. 如何创建独立的UE4服务端
  2. DDD开发框架ABP之本地化资源的数据库存储扩展
  3. NSIS 的简介
  4. idea中maven项目xml资源文件无法读取
  5. Unity光照
  6. 问答精华-IntelliJ IDEA快捷键大全
  7. Oracle数据库备份与恢复的常用方法
  8. 【Android 界面效果45】ViewPager源码分析
  9. 安装centos 7 体验安装过程
  10. php100 编程小技巧
  11. php如何修改SESSION的生存时间
  12. CentOs上搭建git服务器
  13. 自适应网页设计/响应式Web设计
  14. 学习python的第一个小目标:通过requests+xlrd实现简单接口测试,将测试用例维护在表格中,与脚本分开。
  15. 允许mysql用户从远程登录
  16. SpringBoot+gradle项目构建war
  17. jupyter notebook 动态图显示
  18. ubuntu10.04换官方源
  19. 深入MySQL复制(三):半同步复制
  20. windows下 zookeeper

热门文章

  1. Sql Server 常用操作2
  2. SQL Server 大数据量分页建议方案
  3. Spark难道比oracle性能还差?百万级数据测试性能
  4. ORACLE导入、导出命令使用方法
  5. webpack配置
  6. Devexpress 汉化
  7. Android volley 当用fiddler2 抓包时隔一段时间不操作,会出现 http 408错误
  8. 【react学习笔记】-jsx
  9. WPF 自定义TextBox,可控制键盘输入内容
  10. 基于Moodle的IT课程辅助教育平台搭建