Итак, у меня есть серия текстовых полей в ячейках UITableView, которая находится в UIViewController (а не в контроллере табличного представления). Я могу редактировать текстовые поля, но методы делегата, такие как - (BOOL) textFieldShouldBeginEditing: (UITextField *) textField, не вызываются.Методы делегатов UITextField, которые не называются
мнение контроллер имеет свой делегат набор:
@interface NRSignUpViewController : UIViewController<UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDelegate, UITableViewDataSource>
объявлены поля:
@property (nonatomic, strong) UITextField *firstName;
@property (nonatomic, strong) UITextField *lastName;
@property (nonatomic, strong) UITextField *email;
и делегатов устанавливаются в viewDidLoad:
_firstName.delegate = self;
_lastName.delegate = self;
_email.delegate = self;
Вот cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Cell"];
cell.accessoryType = UITableViewCellAccessoryNone;
}
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, table.frame.size.width-20, 30)];
tf.textColor = [UIColor blackColor];
tf.returnKeyType = UIReturnKeyNext;
switch (indexPath.row) {
case 0:
tf.placeholder = @"First name";
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
_firstName = tf;
break;
case 1:
tf.placeholder = @"Last name";
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
_lastName = tf;
break;
case 2:
tf.placeholder = @"Email address";
tf.autocapitalizationType = UITextAutocapitalizationTypeNone;
tf.keyboardType = UIKeyboardTypeEmailAddress;
_email = tf;
break;
default:
break;
}
[cell.contentView addSubview:tf];
return cell;
}
Любые идеи, что может отсутствовать?
Для Swift: убедитесь, что делегат метода не в частном расширения; они все еще могут быть в нормальном расширении, хотя – iwasrobbed