5

我的应用程序在 ios 7 中运行没有问题,但是当我在 ios 6 中运行它时它会出现故障。报告是:

2013-10-17 22:58:45.509 Santarem Guide[606:c07] -[_UIAppearance setTintColor:]: unrecognized selector sent to instance 0xa149390
2013-10-17 22:58:45.510 Santarem Guide[606:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIAppearance setTintColor:]: unrecognized selector sent to instance 0xa149390'
*** First throw call stack:
(0x29d8012 0x1951e7e 0x2a634bd 0x29c7bbc 0x29c794e 0x7ade 0x8967b7 0x896da7 0x897fab 0x8a9315 0x8aa24b 0x89bcf8 0x2e69df9 0x2e69ad0 0x294dbf5 0x294d962 0x297ebb6 0x297df44 0x297de1b 0x8977da 0x89965c 0x2dfd 0x20fa725)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

有人遇到这个问题吗?

在我的 App Delegate 中,我有 [[UIView appearance] setTintColor:[UIColor whiteColor]]; 如果我把它变成 [[UIView 外观] setBackgroundColor:[UIColor whiteColor]]; 我收到一个新错误

2013-10-17 23:08:58.310 Santarem Guide[659:c07]-[UITableView setTintColor:]:无法识别的选择器发送到实例 0x1138aa00

一切都变白了。

4

3 回答 3

10

您应该在使用之前检查该方法是否可用。

if ([[UIView appearance] respondsToSelector:@selector(setTintColor:)]) {
    [[UIView appearance] setTintColor:[UIColor whiteColor]];
}
于 2013-10-17T22:17:20.440 回答
2

检查目标设备是否兼容 iOS7:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    [[UIView appearance] setTintColor:[UIColor whiteColor]];
}
于 2014-05-09T09:12:33.587 回答
1

所以我发现,我有几个错误,因为我使用了一些 ios6 不支持的代码。我不得不把

if (SYSTEM_VERSION_LESS_THAN(@"7.0")) {
        // code here 
} else { 
   code here
}

在项目的很多部分让他可以在 ios6 中运行。另一个问题是我也在使用我的 3D 地图。

感谢您的回复

在这种情况下,您必须在类中包含以下宏或在.pch-file中包含全局

#define SYSTEM_VERSION_LESS_THAN(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
于 2013-10-17T22:46:51.677 回答