swift – #selector的参数不能引用属性
发布时间:2020-12-14 05:29:09 所属栏目:百科 来源:网络整理
导读:目标是将以下条件更新为 Swift 2.2语法,该语法建议使用#selector或显式构建Selector. if activityViewController.respondsToSelector("popoverPresentationController") {} 但是,使用以下作为替换失败并生成错误,说#selector的参数不能引用属性 if activityV
目标是将以下条件更新为
Swift 2.2语法,该语法建议使用#selector或显式构建Selector.
if activityViewController.respondsToSelector("popoverPresentationController") { } 但是,使用以下作为替换失败并生成错误,说#selector的参数不能引用属性 if activityViewController.respondsToSelector(#selector(popoverPresentationController)) { } 使用#selector实现此检查的正确方法是什么?
您可以使用以下内容:
if activityViewController.respondsToSelector(Selector("popoverPresentationController")) { } 或者,如果您只针对iOS if #available(iOS 8.0,*) { // You can use the property like this activityViewController.popoverPresentationController?.sourceView = sourceView } else { } 或者,如果您的代码不仅限于iOS #if os(iOS) if #available(iOS 8.0,*) { activityViewController.popoverPresentationController?.sourceView = sourceView } else { } #endif (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- React 可视化开发工具 Shadow Widget 非正经入门(之四:fl
- 玩转extjs5之Ext.data.proxy.Ajax(六)
- 【.net】“Newtonsoft.Json”已拥有为“Microsoft.CSharp”
- DWR实现文件动态读取
- Oracle Service Bus (OSB) 12c 的配置安装
- Cocos2d-x-2.2.1如何创建工程,以及如何将工程独立出来
- Ajax基础知识总结
- E0144"const char *" 类型的值不能用于初始化 "
- Cocos2d-x3.3利用TileMap绘制Polygon/PolyLine
- ios – swift:如何在不使用UIImagePickerController的情况