如何在uitextfield委托方法中获取单元格索引路径? [英] How to get cell indexpath in uitextfield Delegate Methods?

查看:173
本文介绍了如何在uitextfield委托方法中获取单元格索引路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在自定义单元格中有两个文本字段如何在textfield委托方法中获取Tableview单元格的索引路径值我想从用户获取输入值并将其保存到relavent对象。用户可以通过单击单元格中的按钮(添加更多)来添加更多单元格。

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 the relavent object. the user can add more cells by clicking button(Add More) in cell..

提前致谢...

推荐答案

更新到iOS7!

现在,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];

这篇关于如何在uitextfield委托方法中获取单元格索引路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆