Tôi đang sử dụng UITextField trong ứng dụng của mình. Tôi đang sử dụng [texfield becomeFirstResponder]
. Điều này hoạt động tốt và tải bàn phím khi khung nhìn được tải. Tuy nhiên, lỗi này xuất hiện khi tôi nhấp vào UITextField một lần nữa sau khi nó đã được đưa lên. Tôi không hiểu chính xác lý do tại sao, nhưng đây là kết quả tôi nhận được:Ngữ cảnh không hợp lệ 0x0 trên UITextField (Xcode 5)
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.
Đây là mã của tôi:
// 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.
}
bạn có thể đăng thêm một số mã không. ? – Priyatham51
Tôi có nghĩa là tôi không thực sự biết bao nhiêu mã nguồn tôi có thể thêm lol. Nó khá tự giải thích. Tôi đã chỉnh sửa nó mặc dù @ Priyatham51 – Zack
Đó là điều tuyệt vời về lỗi này. Bạn có thể tạo lại nó bằng mã không - bạn thậm chí không cần ổ cắm vào trường văn bản. Tuy nhiên, để tạo lại cảnh báo, trường văn bản cần phải hoàn toàn trống khi bạn nhấn đúp. Hơn nữa, lỗi này vẫn tồn tại trong iOS 7.0.3 cả trong trình mô phỏng và trên thiết bị. – bilobatum