의 일부인 UITableView
에 UITableViewCell
에 UITextField
이 있습니다. TextFields
이 보이고 그들을 클릭 할 수 있습니다 (키보드가 나타납니다). 그러나 textFieldShouldReturn
메서드는 작동하지 않습니다. 이 같은 위임합니다textFieldShouldReturn이 UITableViewCell의 UITextField에서 응답하지 않았습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
VVUserInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:cellUserIdentifier forIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.userData.delegate = self;
[cell.typeLabel setText: array[indexPath.row][0]];
[cell.userData setTextAlignment: NSTextAlignmentRight];
return cell;
은}
-(BOOL)textfieldShouldReturn:(UITextField*)textField{
NSError* e = nil;
NSLog(@"HEJ!");
switch (textField.tag) {
case 0:
arrayStr = [textField.text componentsSeparatedByString:@" "];
self.currentAttendee.firstName = arrayStr[0];
self.currentAttendee.lastName = arrayStr[1];
break;
case 1:
self.currentAttendee.username = textField.text;
break;
case 2:
self.currentAttendee.email = textField.text;
break;
case 3:
arrayStr = [textField.text componentsSeparatedByString:@" "];
self.currentAttendee.firstName = arrayStr[0];
self.currentAttendee.lastName = arrayStr[1];
break;
case 4:
self.currentAttendee.username = textField.text;
break;
case 5:
self.currentAttendee.email = textField.text;
break;
default:
break;
}
[textField resignFirstResponder];
return YES;
[self.currentAttendee.managedObjectContext save:&e];
NSAssert(!e,@"Error saving to API: %@",e);
}
나는 textfieldshould 반환의 내부 brakepoint을 만들었지 만 거기 가지 않았다.
편집 : userData는 내 TextField입니다.
텍스트 필드의 위임을 설정 했습니까 ??? –