我有一个UITableViewCell
(自定义单元格),我在其中创建一些按钮和文本字段并将标签分配给按钮和文本字段。但我无法在单击按钮时获得按钮标题和文本字段值。
在cellForRowAtIndexPath
`[((CustomCell *) cell).btn setTag:rowTag];
[((CustomCell *) cell).textField2 setTag:rowTag+1];`
-(IBAction)submitBtnAction:(UIControl *)sender
{
for (int i=0; i<[self->_dataArray count]; i++)
{
NSIndexPath *myIP = [NSIndexPath indexPathForRow:i inSection:0];
NSLog(@"myIP.row %d",myIP.row);
UITableViewCell *cell = [tblView1 cellForRowAtIndexPath:myIP];
NSLog(@"tag %d",cell.tag);
UIButton *btn = (UIButton *)[cell.contentView viewWithTag:i];
NSLog(@"btn text %@, tag %d",btn.titleLabel.text,btn.tag);
UITextField *tf = (UITextField *)[cell.contentView viewWithTag:i+1];
NSLog(@"tf text %@, tag %d",tf.text,btn.tag);
}
}
我收到这样的错误
-[UITableViewCellContentView titleLabel]: unrecognized selector sent to instance 0x71844e0
2013-07-17 13:48:29.998 Text[1271:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellContentView titleLabel]: unrecognized selector sent to instance 0x71844e0'