UITextField 上的上下文 0x0 无效(Xcode 5) [英] Invalid context 0x0 on UITextField (Xcode 5)
本文介绍了UITextField 上的上下文 0x0 无效(Xcode 5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用中使用了 UITextField.我正在使用 [texfield becomeFirstResponder]
.这工作得很好,并在加载视图时加载键盘.但是,当我在 UITextField 出现后再次单击它时会出现此错误.我不明白为什么,但这是我得到的输出:
I am using a UITextField in my app. I am using [texfield becomeFirstResponder]
. This works just fine and loads the keyboard when the view is loaded. However, this error comes up when I click on the UITextField again after it has been brought up. I don't understand exactly why, but here is the output I am getting:
CGContextSetFillColorWithColor: invalid context 0x0.
CGContextSetStrokeColorWithColor: invalid context 0x0.
CGContextSaveGState: invalid context 0x0.
CGContextSetFlatness: invalid context 0x0.
CGContextAddPath: invalid context 0x0.
CGContextDrawPath: invalid context 0x0.
CGContextRestoreGState: invalid context 0x0.
CGContextSaveGState: invalid context 0x0.
CGContextSetFlatness: invalid context 0x0.
CGContextAddPath: invalid context 0x0.
CGContextDrawPath: invalid context 0x0.
CGContextRestoreGState: invalid context 0x0.
这是我的代码:
// ViewController.h
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *textField;
@end
// ViewController.m
@synthesize textField;
- (void)viewDidLoad
{
[textField becomeFirstResponder];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
推荐答案
我相信您已经发现了一个 iOS 错误(或者至少是一个模拟器错误).您可以更简单地重现它:
I believe you've found an iOS bug (or at least a simulator bug). You can reproduce it even more simply:
- 新建项目(单视图)
- 将 UITextField 拖到 Storyboard 上
- 运行
- 点击 UITextField.
- 点击关闭 UITextField
- 点击 UITextField
- (在某些情况下,您需要再次单击关闭 UITextField)
- 观察错误
我建议打开雷达.
这篇关于UITextField 上的上下文 0x0 无效(Xcode 5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文