У меня есть UIViewController
с UITableView
в нем. В tableview есть настроенные ячейки с текстовыми полями внутри него. Делегаты текстового поля настроены на этот класс.UITableView's didSelectRowAtIndexPath метод не получает вызов
При редактировании текстового поля (textFieldDidBeginEditing
) У меня есть раскрывающийся список (UIView
с табличным просмотром). Выпадающий список создается программно. Проблема, с которой я столкнулся, - это не didSelectRowAtIndexPath
выпадающего меню. Я правильно поставил делегат, источник данных для класса. Я также удалил все остальные жесты. Я убедился, что tableview не находится в режиме редактирования.
По щелчкам ячеек в раскрывающемся списке единственное, что работает, это методы делегата моего текстового поля моего фона.
//UITableView class(with textfield from where dropdown is loaded.)
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if(textField.tag == 3){
if(dropDown == nil) {
CGFloat f = 200;
dropDown = [[SFTextFieldDropDown alloc] showDropDownWithSender:textField withHeight:f andElements:self.list];
dropDown.delegate = self;
}
}
}
// Custom Drop down class.
- (id)showDropDownWithSender:(UITextField *)senderTextField withHeight:(CGFloat)height andElements:(NSArray *)array{
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, btn.size.width, 0)];
table.delegate = self;
table.dataSource = self;
table.layer.cornerRadius = 5;
table.backgroundColor = [UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1];
table.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
table.separatorColor = [UIColor grayColor];
[table setAllowsSelection:YES];
table.frame = CGRectMake(0, 0, btn.size.width, *height);
[table setEditing:NO];
[self addSubview:table];
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.list count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.font = [UIFont systemFontOfSize:15];
cell.textLabel.textAlignment = NSTextAlignmentLeft;
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
}
if([list count] > 0)
cell.textLabel.text = [list objectAtIndex:indexPath.row];
return cell;
}
Показать свой код .. –
Пожалуйста, добавьте ваш код для лучшего обзора –
Добавили ли вы какой-либо жест вашему мнению ?? –