本文介绍了UISearchBar CGContext ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



- (BOOL)searchBarShouldBeginEditing之后,我有一个视图中的UISearchBar :(UISearchBar *)searchBar



将其发送到控制台:

它重复相同的错误。我想知道究竟是什么问题?



我相信有一个 NULL 上下文,但它与一个UISearchBar ?
tnx。

解决方案

这是苹果正在开发的一个已知问题。



请在这里查看:



编辑:对于那些在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];
}





   - (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];
}




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:

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

- (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];
}
- (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];
}  

这篇关于UISearchBar CGContext ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:17