2015-04-24 22 views
0

我在屏幕上有两个文本框,但只有第二个文本框没有收到触摸事件。我检查了背景色并已将setDelegate设置为self.First textfield工作正常。我以编程方式创建了文本框。这里是我的代码:UITextField没有收到触摸事件

txtMsg = [[UITextField alloc] init]; 
txtMsg.delegate = self; 
txtMsg.placeholder = @"Type your message here.."; 
txtMsg.frame = CGRectMake(10, 190, 300, 40); 
txtMsg.textColor = [UIColor blackColor]; 
txtMsg.layer.borderColor = [UIColor lightGrayColor].CGColor; 
txtMsg.layer.borderWidth = 1.0f; 
txtMsg.backgroundColor = [UIColor blueColor]; 
txtMsg.autocapitalizationType = UITextAutocapitalizationTypeNone; 
txtMsg.autocorrectionType = UITextAutocorrectionTypeNo; 
txtMsg.font = [UIFont systemFontOfSize:16]; 
[txtMsg setBorderStyle:UITextBorderStyleLine]; 
[self.view addSubview:txtMsg]; 

任何想法是什么错?

+0

您创建了两个文本框编程吧? – micky

+0

它对我来说工作得很好! – micky

+0

你可以用两个文本框编写代码吗? –

回答

0

尝试添加:

yourTextField.userInteractionEnabled = YES;