zoukankan      html  css  js  c++  java
  • iOS——自定义Segue实现总结

    在阅读了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:](传递数据)  --> [-(IBAction)returnFromSegue:(UIStoryboardSegue *)sender] (IBAction relative by unwind segue id which defined in storyboard)

     

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

  • 相关阅读:
    Python语法入门之基本数据类型
    ASCII,GBK,和Unicode的UTF-8,UTF-16,UTF-32阐述
    为什么计算机只认识0和1?
    Intel万兆网卡82599linux驱动安装
    Django自定义分页器
    Django图片防盗链
    Django配置用户上传文件夹和暴露后端文件夹资源
    Django之TruncMonth截取日期作为新的虚拟字段使用
    第十一篇:auth模块
    第十篇:跨站请求伪造csrf
  • 原文地址:https://www.cnblogs.com/lihaiyin/p/4431628.html
Copyright © 2011-2022 走看看