Всякий раз, когда вы создаете подпредставления (кнопки, текстовые поля и т. Д.) Для своих UITableViewCell
, не забудьте отметить их .
myTextField.tag = 0;
myTextLabel.tag = 1;
[cell addSubview:myTextField];
[cell addSubview:myTextLabel];
После того, как вы пометили, вы можете получить к ним доступ, используя метод ниже.
- (UIView *)viewWithTag:(NSInteger)tag
Когда вы выберете, вы можете получить подпредставления вашего UITableViewCell, используя ViewWithTag
функцию UIView
.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableview cellForRowAtIndexPath:indexPath];
UITextField* myTextField = [cell viewWithTag:0];
UILabel* myTextLabel = [cell viewWithTag:1];
}