Comment on page
01 使用KVC设置UIAlertAction按钮颜色的Crash
=> Start [<UIAlertAction 0x1702b63e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _titleTextColor.
-> translating『 0x1005eb9a0 』=> -[UsedHouseDetail firstCollectTip] QFangWang/HouseDetail/Controller/UsedHouseDetail.m: line 509
-> translating『 0x1005eb668 』=> __39-[UsedHouseDetail RequestColletionData]_block_invoke.481 QFangWang/HouseDetail/Controller/UsedHouseDetail.m: line 472
-> translating『 0x1007b0cfc 』=> -[YTKNetworkAgent handleRequestResult:] /Users/Fish/iOS-Client/QFangWang/Pods/YTKNetwork/YTKNetwork/YTKNetworkAgent.m: line 262
-> translating『 0x1007b020c 』=> __33-[YTKNetworkAgent ytk_addRequst:]_block_invoke.145 /Users/Fish/iOS-Client/QFangWang/Pods/YTKNetwork/YTKNetwork/YTKNetworkAgent.m: line 156
-> translating 『 0x100227524 』=> main QFangWang/main.mm: line 13
=> End [<UIAlertAction 0x1702b63e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _titleTextColor.
>------------------------------------------------------<
最近线上发现了如上面所示的bug
是为了实现改变
UIAlertAction
默认按钮颜色的地方使用了下面方式[action setValue:[UIColor redColor] forKey:@"_titleTextColor"];
但是在某些系统版本中
UIAlertAction
中并没有 _titleTextColor
这个成员变量而导致了崩溃 具体可以通过 runtime
获取成员列表来看看判断是否有
_titleTextColor
来设置 或者 通过设置 alertController.view.tintColor
来实现 需要注意的是: 在8.4上由于层级结构的问题 需要在 presentAlertVC
后设置 tintColor
Last modified 2yr ago