iOS Swift: anonymous instance not used

Problem:

method of anonymous instance not called.

let dest = SomeController()
dest.modalPresentationStyle = .custom
//new instance, animationController will not be called
detail.transitioningDelegate = SomeDelegate() 
present(detail, animated: true, completion: nil)

Cause:

weak reference

Solution:

extract instance to class property

...
fileprivate let mDelegate = SomeDelegate()
...
let dest = SomeController()
dest.modalPresentationStyle = .custom
detail.transitioningDelegate = self.mDelegate
present(detail, animated: true, completion: nil)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 创建一个Vue项目,如果你已经安装了npm1.vue init webpack GoGo(包名称) 2.npm ...
    一个人一匹马阅读 1,387评论 0 1
  • 我的小男神终于睡着啦~ 隔着黑夜我也能感觉到他又长又卷的睫毛,他的爸爸妈妈可都没这个基因,忽闪忽闪着圆圆的眼睛,拉...
    将心向月阅读 1,675评论 0 0

友情链接更多精彩内容