我已经在我的iOS应用程序中以编程方式创建了两个UITextField
s,并分别将它们的文本设置为_minPrice
和_minPrice
变量。UITextFields不允许我编辑文本
_minPrice
和_maxPrice
值在两个字段中正确显示,但在它们上点击不允许用户编辑它们,它们只是保留那些静态值,退格不起作用。有什么关于我的代码,这阻止了文本字段被编辑?
// Min Price
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(-25, -76, 70, 30)];
tf.textColor = [UIColor blackColor];
tf.font = [UIFont fontWithName:@"Helvetica-Neue" size:14];
tf.backgroundColor=[UIColor whiteColor];
tf.text= _minPrice;
tf.textAlignment = NSTextAlignmentCenter;
tf.layer.cornerRadius=8.0f;
tf.layer.masksToBounds=YES;
tf.layer.borderColor=[[UIColor lightGrayColor]CGColor];
tf.layer.borderWidth= 1.0f;
// Max Price
UITextField *tf1 = [[UITextField alloc] initWithFrame:CGRectMake(100, -76, 70, 30)];
tf1.textColor = [UIColor blackColor];
tf1.font = [UIFont fontWithName:@"Helvetica-Neue" size:14];
tf1.backgroundColor=[UIColor whiteColor];
tf1.text= _maxPrice;
tf1.textAlignment = NSTextAlignmentCenter;
tf1.layer.cornerRadius=8.0f;
tf1.layer.masksToBounds=YES;
tf1.layer.borderColor=[[UIColor lightGrayColor]CGColor];
tf1.layer.borderWidth= 1.0f;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 200, 400, 400)];
[view addSubview:tf];
[view addSubview:tf1];
[self.view addSubview:view];
也许他们看到了如何打字。 ;) – 2014-09-25 21:01:25