[UITableView] TableView에 TextField, Switch 붙이기
case 0: {
[cell.textLabel setText:@"ID :"];
[cell.textLabel setTextAlignment:UITextAlignmentRight];
UIView *viewCell = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, 40)];
UITextField *textUserID = [[UITextField alloc] initWithFrame:CGRectMake(0, 10, 160, 31)];
[viewCell addSubview:textUserID];
[textUserID setTag:0];
[textUserID setText:[dictUserData objectForKey:@"ID"]];
[textUserID setReturnKeyType:UIReturnKeyDone];
[textUserID setAutocorrectionType:UITextAutocorrectionTypeNo];
[textUserID setClearButtonMode:UITextFieldViewModeWhileEditing];
[textUserID setClearsOnBeginEditing:NO];
self.stringID = textUserID.text;
[textUserID addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingChanged];
cell.accessoryView = viewCell;
[textUserID release];
[viewCell release];
break;
}
case 1: {
[cell.textLabel setText:@"Password :"];
[cell.textLabel setTextAlignment:UITextAlignmentRight];
UIView *viewCell = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, 40)];
UITextField *textUserPW = [[UITextField alloc] initWithFrame:CGRectMake(0, 10, 160, 31)];
[viewCell addSubview:textUserPW];
[textUserPW setTag:1];
[textUserPW setText:[dictUserData objectForKey:@"PW"]];
[textUserPW setSecureTextEntry:YES];
[textUserPW setReturnKeyType:UIReturnKeyDone];
[textUserPW setAutocorrectionType:UITextAutocorrectionTypeNo];
[textUserPW setClearButtonMode:UITextFieldViewModeWhileEditing];
[textUserPW setClearsOnBeginEditing:NO];
[textUserPW addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingChanged];
cell.accessoryView = viewCell;
[textUserPW release];
[viewCell release];
break;
}
default: {
[cell.textLabel setText:@"자동 저장 :"];
[cell.textLabel setTextAlignment:UITextAlignmentRight];
UIView *viewCell = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, 40)];
UISwitch *switchAutoSave = [[UISwitch alloc] initWithFrame:CGRectMake(0, 6, 94, 27)];
if ([[NSUserDefaults standardUserDefaults] stringForKey:@"ID"] ) [switchAutoSave setOn:YES animated:NO];
else [switchAutoSave setOn:NO animated:NO];
[viewCell addSubview:switchAutoSave];
[switchAutoSave addTarget:self action:@selector(autoSaveChange:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = viewCell;
[switchAutoSave release];
[viewCell release];
break;
}