Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My app closes in ios6 with UIAppearance setTintColor

my app is running with no problem in ios 7 but when i run it in ios 6 it goes down. The report is:

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) 

Does anyone had this problem?

In my App Delegate i have [[UIView appearance] setTintColor:[UIColor whiteColor]]; and if i turn it this to [[UIView appearance] setBackgroundColor:[UIColor whiteColor]]; i get a new error that is

2013-10-17 23:08:58.310 Santarem Guide[659:c07] -[UITableView setTintColor:]: unrecognized selector sent to instance 0x1138aa00

and all gets white.

like image 839
Osvaldo Cipriano Avatar asked Oct 17 '13 22:10

Osvaldo Cipriano


3 Answers

You should check if the method is available before use it.

if ([[UIView appearance] respondsToSelector:@selector(setTintColor:)]) {
    [[UIView appearance] setTintColor:[UIColor whiteColor]];
}
like image 104
JeroValli Avatar answered Nov 09 '22 14:11

JeroValli


Check whether target device is iOS7-compatible:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    [[UIView appearance] setTintColor:[UIColor whiteColor]];
}
like image 21
Keith OYS Avatar answered Nov 09 '22 12:11

Keith OYS


So i figured out, i had several errors because i was using some code that ios6 does not support. I had to put

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

In many parts of the project so he could run in ios6. Another problem was i was also using my map with 3D.

Thanks for the replies

In this case you have to include following macro in the class or global in .pch-file

#define SYSTEM_VERSION_LESS_THAN(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
like image 1
Osvaldo Cipriano Avatar answered Nov 09 '22 13:11

Osvaldo Cipriano