我在方法cellForRowAtIndexPath
中将标签设置为
cell.noOfCommentsButton.tag=indexPath.row;
noOfCommentsButton
我的UIButton在哪里。
我已经为此按钮定义IBAction为:
- (IBAction)showComments:(BlogCell *)sender{
int tag=[(UIButton *)sender.noOfCommentsButton tag];
NSLog(@"The tag clicked:%d",tag);
}
其中Blogcell是我的自定义单元格类。
但是我在电话中遇到了一个例外NSLog(@"The tag clicked:%d",tag);
,我不知道为什么。
- (IBAction)showComments:(BlogCell *)发送{
这是错误的-sender
是按钮,而不是单元格。所以应该是:
- (IBAction)showComments:(UIButton *)sender {
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句