【问题标题】:My app closes in ios6 with UIAppearance setTintColor我的应用程序在 ios6 中使用 UIAppearance setTintColor 关闭
【发布时间】:2013-10-26 14:53:43
【问题描述】:

我的应用程序在 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 外观] setTintColor:[UIColor whiteColor]];如果我把它变成 [[UIView 外观] setBackgroundColor:[UIColor whiteColor]];我收到一个新错误,即

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

一切都变白了。

【问题讨论】:

  • 有些方法在SDK版本之间有折旧,使用前请检查该方法是否可用。
  • 我如何查看哪个已弃用?
  • if([[UIView appearance] respondsToSelector:@selector(setTintColor:)]){ [[UIView appearance] setTintColor:[UIColor whiteColor]]; } 这个。
  • 请不要忘记标记正确答案!

标签: ios uiview uiappearance tintcolor


【解决方案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)

【讨论】:

    【解决方案2】:

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

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
        [[UIView appearance] setTintColor:[UIColor whiteColor]];
    }
    

    【讨论】:

      【解决方案3】:

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

      if ([[UIView appearance] respondsToSelector:@selector(setTintColor:)]) {
          [[UIView appearance] setTintColor:[UIColor whiteColor]];
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-22
        • 2011-11-10
        • 1970-01-01
        • 2023-03-29
        • 2012-11-10
        相关资源
        最近更新 更多