gpt4 book ai didi

ios - UISearchBar CGContext 错误

转载 作者:IT王子 更新时间:2023-10-29 07:35:34 24 4
gpt4 key购买 nike

我在 View 中有一个 UISearchBar,每当我在键盘出现后点击它 -

-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar 之后

它将此发送到控制台:

<Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. 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.

它重复了同样的错误。我想知道到底是什么问题?

我相信那里有一个 NULL 上下文,但它与 UISearchBar 有什么关系?谢谢。

最佳答案

这是 Apple 正在努力解决的一个已知问题。应在下一个测试版中修复。

看看这里:Xcode Number pad with decimal error

编辑:对于那些对文本字段有疑问的人,也许这应该可以解决您的问题:

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

关于ios - UISearchBar CGContext 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17777928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com