UISearchBar CGContext ERROR [英] UISearchBar CGContext ERROR
问题描述
在 - (BOOL)searchBarShouldBeginEditing之后,我有一个视图中的UISearchBar :(UISearchBar *)searchBar
将其发送到控制台:
<错误> ;:
CGContextSetStrokeColorWithColor
:无效上下文0x0
。这个
是一个严重的错误。这个应用程序或其使用的库正在使用
无效的上下文,从而有助于系统稳定性和可靠性的总体的
降低。此通知是一个
礼貌:请解决这个问题。它将在
即将到来的更新中成为致命错误。
它重复相同的错误。我想知道究竟是什么问题?
我相信有一个 NULL 上下文,但它与一个UISearchBar ?
tnx。
这是苹果正在开发的一个已知问题。
请在这里查看: Xcode Number pad with decimal error
编辑:对于那些在textfield有问题的人应该帮助你:
我找到了这个问题的修复!我有3个应用程序,这是现在打破,所以,对我...这是一个很好的发现。找到解决方案StackOverflow ...结合两个答案一个类似的问题。
在我的情况下,用户点击一个barButtonItem和一个警报或对话框出现。 / p>
我看到的最大的区别是如何分配UIAlertView。
NEW WAY的文本框显示出来,并显示出它应该的键盘。
我现在可以看到textField,输入文本按我期望的方式工作。添加initWithFrame对textField放置没有任何影响。
旧版....
- (IBAction)addEntryTapped:(id)sender
{
[_editorTextView resignFirstResponder];
[self saveTextChanges];
[self dismissPopovers];
_prompt = [[UIAlertView alloc] initWithTitle:@新条目标题...
消息:@\\\
\\\
\\\
//重要
委托:self
cancelButtonTitle:@Cancel
otherButtonTitles:@OK,nil];
_textField = [[UITextField alloc] initWithFrame:CGRectMake(17.0,55.0,250.0,25.0)];
[_textField setBackgroundColor:[UIColor whiteColor]];
[_textField setPlaceholder:@New Entry Title];
_textField.borderStyle = UITextBorderStyleRoundedRect;
_textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
[_prompt addSubview:_textField];
[_prompt show];
//设置游标并显示
[_textField becomeFirstResponder];
}
NEW WAY ...
- (IBAction)addEntryTapped:(id)sender
{
[_editorTextView resignFirstResponder ];
[self saveTextChanges];
[self dismissPopovers];
_prompt = [[UIAlertView alloc] init];
_prompt.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * text = [_prompt textFieldAtIndex:0];
_textField = text;
[_prompt setDelegate:self];
[_prompt setTitle:@New Entry Title ...];
[_prompt setMessage:@];
[_prompt addButtonWithTitle:@Cancel];
[_prompt addButtonWithTitle:@OK];
[_textField setPlaceholder:@New Entry Title];
_textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
[_prompt show];
//设置游标并显示键盘
[_textField becomeFirstResponder];
}
讯息由Popeye7于9/25 / 13 at 12:25 PM
讯息由Popeye7于9/25/13于12:33编辑
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´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
I have found a fix for this issue! I have 3 apps that this is now broken on, so, to me... this is a good find. Found the solution on StackOverflow... combined two answers to a similar question.
In my case, a user taps a barButtonItem and an "alert" or dialog appears.
I see the big difference is in how the UIAlertView is allocated. The "NEW WAY" has the textField showing and brings up the keyboard as it should.
I am now able to see the textField, enter text and it works the way I expect it to. Adding the "initWithFrame" back in has no affect on the textField placement.
OLD WAY....
- (IBAction)addEntryTapped:(id)sender
{
[_editorTextView resignFirstResponder];
[self saveTextChanges];
[self dismissPopovers];
_prompt = [[UIAlertView alloc] initWithTitle:@"New Entry Title..."
message:@"\n\n\n" // IMPORTANT
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
_textField = [[UITextField alloc] initWithFrame:CGRectMake(17.0, 55.0, 250.0, 25.0)];
[_textField setBackgroundColor:[UIColor whiteColor]];
[_textField setPlaceholder:@"New Entry Title"];
_textField.borderStyle = UITextBorderStyleRoundedRect;
_textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
[_prompt addSubview:_textField];
[_prompt show];
// set cursor and show
[_textField becomeFirstResponder];
}
NEW WAY...
- (IBAction) addEntryTapped:(id)sender
{
[_editorTextView resignFirstResponder];
[self saveTextChanges];
[self dismissPopovers];
_prompt = [[UIAlertView alloc] init];
_prompt.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField *text = [_prompt textFieldAtIndex:0];
_textField = text;
[_prompt setDelegate:self];
[_prompt setTitle:@"New Entry Title..."];
[_prompt setMessage:@""];
[_prompt addButtonWithTitle:@"Cancel"];
[_prompt addButtonWithTitle:@"OK"];
[_textField setPlaceholder:@"New Entry Title"];
_textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
[_prompt show];
// set cursor and show keyboard
[_textField becomeFirstResponder];
}
Message was edited by Popeye7 on 9/25/13 at 12:25 PM
Message was edited by Popeye7 on 9/25/13 at 12:33 PM
这篇关于UISearchBar CGContext ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!