我正在尝试创建一个 UITableView 以允许用户输入数据,类似于许多设置 UITableViews,带有一些文本字段和标注到其他表格视图的复选框。对于应用程序中的这种常见功能,这似乎不是很简单。
我无法从自定义 UITableViewCell 访问 indexPath.row。这是我分配自定义 UITableViewCell 的地方。
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[TextFieldCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
在我的 TextField 类的@implementation 中,在 - (id)initWithStyle: 中,我试图通过以下方式访问 indexPath:
NSIndexPath *indexPath = [(UITableView *)self.superview indexPathForCell:self];
...为了设置文本字段的标签,如:
textRow = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 21)];
textRow.tag = [indexPath row];
任何人都可以阐明我的问题或指出我以编程方式创建基本设置样式的 TableViews 的方向。
谢谢