(他のものに加えて)という名前のカスタムUItableViewCell
クラスがあり、その. デリゲート メソッドでは、それがどのセクションに属しているかを検出しようとしています。このような:EditableTableViewCell
UITextField
contentView
Textfield
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
UIView* contentView =[textField superview];
//traverse up in the view hierarchy until we find the cell's content view.
while (![contentView isKindOfClass:[EditableTableViewCell class]] || contentView.superview == nil) {
contentView = [contentView superview];
}
EditableTableViewCell *thiscell = (EditableTableViewCell*)contentView;
NSIndexPath *indexpath =[[self tableView]indexPathForRowAtPoint:thiscell.center];
これにより正しい結果が得られ 、ビュー階層をナビゲートする同様のソリューションもここで見られました。これが唯一の解決策なのか、それとも利用可能なすべてのセルのループを伴わない、より適切なものがあるのか 疑問に思っています。