このコードを使用している場合、はそのメソッドUITextField
を呼び出しません。delegate
このコードでは、にを追加しUITextField
ていUITableView
ます。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
cell.accessoryType = UITableViewCellAccessoryNone;
if (indexPath.row!=7)
{
[cell.textLabel setTextColor:[UIColor blackColor]];
[cell.textLabel setTextColor:[UIColor blackColor]];
//Creating Lable
UILabel *lblText= [[UILabel alloc] initWithFrame:CGRectMake(53, 30, 150, 35)];
[lblText setFont:[UIFont boldSystemFontOfSize:15.0]];
lblText.backgroundColor=[UIColor clearColor];
lblText.textColor=[UIColor blackColor];
lblText.text = [labelArray objectAtIndex:indexPath.row];
//creating a the textField
UITextField *txtField = [[UITextField alloc] init];
[txtField setFrame:CGRectMake(50, 56, 220, 31)];
[txtField setBackgroundColor:[UIColor whiteColor]];
[txtField setBorderStyle:UITextBorderStyleRoundedRect];
txtField.delegate=self;
[txtField setFont:[UIFont systemFontOfSize:14.0]];
txtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
txtField.userInteractionEnabled=YES;
txtField.enabled=YES;
if (indexPath.row==2)
{
txtField.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
}
else if(indexPath.row==3)
{
txtField.keyboardType=UIKeyboardTypeEmailAddress;
}else
{
txtField.keyboardType=UIKeyboardTypeDefault;
}
if (indexPath.row==6 ||indexPath.row==5)
{
[txtField setSecureTextEntry:YES];
}
txtField.tag=indexPath.row;
[cell addSubview:txtField];
[cell addSubview:lblText];
}
}
return cell;
}