gpt4 book ai didi

ios - swift : equivalent to respondToSelector

转载 作者:搜寻专家 更新时间:2023-11-01 05:54:33 24 4
gpt4 key购买 nike

我搜索过并使用过

UIDevice.currentDevice().instancesRespondToSelector(Selector("userInterfaceIdiom"))

但对我不起作用。将错误显示为

'UIDevice' doesn't have member named 'instancesRespondToSelector`

也试过这个

UIDevice.instancesRespondToSelector(Selector("userInterfaceIdiom"))

但是出现了错误

'UIDevice' doesn't have member named 'userInterfaceIdiom'

但是 UIDevice 属于 NSObject,它有成员 instancesRespondToSelector?请指出我的错误或建议正确的方法吗?

最佳答案

instancesRespondToSelector 仍然是类方法,绝对不是实例方法:

UIDevice.instancesRespondToSelector(Selector("userInterfaceIdiom"))

更新#1

因为 userInterfaceIdiom 只是实例的一个属性:

UIDevice.currentDevice().respondsToSelector(Selector("userInterfaceIdiom"))

关于ios - swift : equivalent to respondToSelector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24119092/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com