我在一个视图里有一个UISearchBar,每当我点击它,在键盘弹出之后-
在-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
之后
它将此消息发送到控制台:
:
CGContextSetStrokeColorWithColor
:无效的上下文0x0
。这是一个严重的错误。此应用程序或其使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体降级。此通知是出于礼貌:请解决此问题。在即将到来的更新中,它将成为一个致命错误。
它重复相同的错误。我想知道到底是什么问题?
我相信存在一个空的上下文,但它与UISearchBar有什么关系呢?tnx。
发布于 2013-07-23 20:33:38
这是苹果正在努力解决的一个已知问题。应该会在下一个beta版本中修复。
看看这里:Xcode Number pad with decimal error
编辑:对于那些对文本字段有问题的人来说,这可能会帮助你解决这个问题:
From Apple Developer Forums bye Popeye7 - So all credits to him
我已经找到了解决这个问题的方法!我有三个应用程序,现在这个坏掉了,所以,对我来说…这是一个很好的发现。在StackOverflow上找到了解决方案...组合了两个类似问题的答案。
在我的例子中,用户点击一个barButtonItem,就会出现一个“警告”或对话框。
我发现最大的区别在于UIAlertView是如何分配的。“新方法”会显示textField,并按需要调出键盘。
我现在可以看到textField,输入文本,它的工作方式与我期望的一样。重新添加"initWithFrame“不会影响textField的放置。
老方法..。
- (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];
}
Popeye7在13年9月25日下午12:25编辑了
消息
消息在时间13年9月25日12:33由Popeye7编辑
发布于 2013-09-26 00:42:36
在从~/库/首选项中删除iOS模拟器首选项后,这个问题就消失了。
转到~/库/首选项将"com.apple.iphonesimulator.plist“拖到垃圾桶中。
有状态
发布于 2013-09-21 13:18:50
似乎是在.xib文件中设置的UISearchBar的AutoLayout约束导致了这个问题。如果有任何多余或冲突的约束没有被编译器捕获,就会导致绘制错误并抛出这些错误。
https://stackoverflow.com/questions/17777928
复制相似问题