gpt4 book ai didi

ios - 如何检查UITableViewCellAccessoryDe​​tailButton的可用性?

转载 作者:行者123 更新时间:2023-11-29 02:45:50 52 4
gpt4 key购买 nike

我需要表格单元格的附件类型与 iOS 7 和 6 兼容。我尝试使用通常的 address check 来测试附件类型的可用性。 , 但编译器在提示

Cannot take the address of an rvalue of type 'NSInteger' (aka 'int')

self.accessoryType = (&UITableViewCellAccessoryDetailButton == nil)
? UITableViewCellAccessoryDetailDisclosureButton
: UITableViewCellAccessoryDetailButton;

最佳答案

无法在运行时检查枚举值是否存在。它只是在编译时转换为整数。

您唯一真正的选择是执行一些其他运行时检查,这些检查在 iOS 6 中会失败,但在 iOS 7(或更高版本)中会成功。

也许是这样:

if ([self respondsToSelector:@selector(separatorInset)]) {
self.accessoryType = UITableViewCellAccessoryDetailButton; // iOS 7 or later
} else {
self.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; // iOS 6
}

此解决方案将来可能会失败,但到那时您可能将不再支持 iOS 6。

关于ios - 如何检查UITableViewCellAccessoryDe​​tailButton的可用性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25146391/

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