Confirmation error in - [UITextFieldLabel setTextColor:]

I received the following failure:

Claim failed in - [UITextFieldLabel setTextColor:], / SourceCache / UIKit_Sim / UIKit-1448.89 / UILabel.m: 314

in this line

[self.window makeKeyAndVisible];

in the appDidFinishLaunching method.

Unhandled exception: Debug info are Invalid parameter not satisfying: color ( "4 libc++abi.dylib 0x991331fe _Z19safe_handler_callerPFvvE + 15", "5 libc++abi.dylib 0x99133268 __cxa_bad_typeid + 0", "6 libc++abi.dylib 0x991342a0 _Z23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0", "7 libobjc.A.dylib 0x0167e416 __objc_personality_v0 + 0", "8 CoreFoundation 0x0182cef8 +[NSException raise:format:arguments:] + 136" ) 

Any help would be appreciated :)

Thanks in advance.

+4
source share
1 answer

I had the same problem and I finally found the cause of the problem.

It seems that [UILabel setTextColor:] crashes (only!) IOS 4.x when null color is passed as a parameter. My app works great on iOS 5 and 6.

I use a navigationBar created with IB that has a UITextField in it (which, as usual, is a subquery of BarButtonItem). This TextField had the TextColor attribute left to it by default. For TextFields that fit into a regular view, this works fine, but not for my TextField in the navigationBar. As soon as I changed TextColor to something else (for example, Dark Text Color), it works fine and does not cause further failure.

It was difficult to identify this problem, as it happens when the application starts, and by the time all the NIB files were loaded, therefore, debugging of codes or exception checkpoints did not work. Even the crash log did not help, as it simply tells you that this happens when the NIB file is downloaded, but does not tell you which one. In my case, a lot of views are loaded at startup. Finally, I was able to track down the problem by creating a class of the UILabel Class class and simply adding the -(void )setTextColor:(UIColor *)color method to this category. In this method, I was able to set a breakpoint and found that the parameter was zero in only one case. In addition, I added -(void )setText:(NSString *)text and looked at what text was set for this particular UILabel, where nil was previously set. The text parameter finally pointed to my UITextField in the navigationBar.

Perhaps this helps in other cases where this failure is not related to the UITextField in the UINavigationBar.

+4
source

Source: https://habr.com/ru/post/1440544/


All Articles