How to get cell indexpath in uitextfield Delegate Methods?

后端 未结 11 983
南旧
南旧 2020-12-08 22:56

I have two textfields in a custom cell how to get the indexpath value of Tableview cell in textfield delegate methods I want to get the input value from user and save it to

11条回答
  •  無奈伤痛
    2020-12-08 23:05

    Update to iOS7!

    With new features in iOS7 now code should be :

    UITableViewCell *textFieldRowCell;
    
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
        // Load resources for iOS 6.1 or earlier
        textFieldRowCell = (UITableViewCell *) textField.superview.superview;
    
    } else {
        // Load resources for iOS 7 or later
        textFieldRowCell = (UITableViewCell *) textField.superview.superview.superview; 
       // TextField -> UITableVieCellContentView -> (in iOS 7!)ScrollView -> Whoola!
    }
    
    NSIndexPath *indexPath = [self.tableView indexPathForCell:textFieldRowCell];
    

提交回复
热议问题