UITableViewCell に追加した標準の UITextField があり、それを編集しようとすると、その中のテキストがクリアされません。プレースホルダーを配置しようとしましたが、編集時にそれもクリアされません。どうしたの?
if (indexPath.row == 1) {
cell.textLabel.text = @"Device ID";
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
deviceID = [[UITextField alloc] initWithFrame:CGRectMake(115, 11, 388, 22)];
deviceID.delegate = self;
deviceID.adjustsFontSizeToFitWidth = YES;
deviceID.font = [UIFont boldSystemFontOfSize:15];
deviceID.textColor = [UIColor blackColor];
deviceID.autocorrectionType = UITextAutocorrectionTypeNo;
deviceID.autocapitalizationType = UITextAutocapitalizationTypeNone;
deviceID.textAlignment = NSTextAlignmentLeft;
deviceID.clearButtonMode = UITextFieldViewModeWhileEditing;
deviceID.keyboardType = UIKeyboardTypeDefault;
deviceID.backgroundColor = [UIColor clearColor];
deviceID.delegate = self;
deviceID.clearsOnBeginEditing = YES;
deviceID.text = [[NSUserDefaults standardUserDefaults] objectForKey:DEVICE_ID];
[deviceID setEnabled:YES];
[cell addSubview:deviceID];
}
- (BOOL)textFieldShouldClear:(UITextField *)textField {
return YES;
}