UITextField:键盘出现,就在我单击它的左侧

时间:2012-07-03 07:16:33

标签: ios uitextfield

为什么它,然后键盘出现,就在我点击UITextField的右边部分?

的cellForRowAtIndexPath:

EditableCell* cell = [[EditableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.reportViewController = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = item.text;

UITextField *textfield = [[UITextField alloc] initWithFrame:CGRectZero];
textfield.text = item.var.value;
textfield.tag = 1;
textfield.font = [UIFont fontWithName:@"Helvetica" size:16];
textfield.textColor = [UIColor colorWithRed:0.22 green:0.33 blue:0.53 alpha:1];
textfield.delegate = cell;

[cell.contentView addSubview:textfield];
return cell;

layoutSubviews:

UITextField* textfield = (UITextField *)[self viewWithTag:1];
textfield.frame = CGRectMake(self.textLabel.frame.origin.x+self.textLabel.frame.size.width+10, 
                             self.textLabel.frame.origin.y, 
                             tableView.frame.size.width-(self.textLabel.frame.origin.x+self.textLabel.frame.size.width)-20, 
                             self.textLabel.frame.size.height);

使用“颜色混合图层”

查看结构

enter image description here

1 个答案:

答案 0 :(得分:0)

是否有其他内容(其他UI项目)覆盖了UITextField的左侧?

您可以使用带有“颜色混合图层”功能的模拟器来显示您的UITextField上是否有任何内容