我在我的应用程序中使用 UITextField。我正在使用[texfield becomeFirstResponder]
. 这工作得很好,并在加载视图时加载键盘。但是,当我在 UITextField 出现后再次单击它时,会出现此错误。我不明白为什么,但这是我得到的输出:
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.
}