I have a UISearchBar inside a view, whenever I tap on it, after the keyboard comes up -
after -(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
it sends this to the console:
<Error>:
CGContextSetStrokeColorWithColor
: invalid context0x0
. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
It repeats the same error. I am wonderring what exactly could be the problem?
I believe there is a NULL context out there but what it has to do with a UISearchBar? tnx.
It appears that the UISearchBar's AutoLayout constraints that are set in the .xib file are causing this problem. If there are any redundant or conflicting constraints that weren't caught by the compiler it can cause a drawing error and throw these errors.
This went away for me after deleting the iOS Simulator preferences from ~/Library/Preferences.
Go to ~/Library/Preferences Drop "com.apple.iphonesimulator.plist" to the trash.
Stateful
This "missing context" thing seems to be a iOS 7 bug and it seems to occur only for empty textfields. I am using a lightweight workaround in my projects until this issue got fixed by Apple (so probably never ;)).
...that did it for me.
EDIT: You need to implement UITextFieldDelegate, of course. EDIT 2: Unfortunately, it didn't work exactly as I expected. The error is gone, but the whitespace-character is not removed most of the time...Anyone got a solution for this? EDIT 3: I am giving up on that issue. This way does not cover up all use cases of UITextField and it decreases the UX.
It´s a known issue on which Apple is working on. Should be fixed in the next beta release.
Have a look here: Xcode Number pad with decimal error
Edit: For those who have that issue with a textfield maybe this should get you around:
From Apple Developer Forums bye Popeye7 - So all credits to him