http://www.cocoachina.com/ask/questions/show/98163?tab=newest
我在UITableViewCell里加了个UISwitch,点击这个UISwitch,出现响应的点击事件怎么做;
[cell.switch addTarget:self action:@selector(switchAction:)forControlEvents:UIControlEventValueChanged];
-(void)switchAction:(id)sender{
//
XXXCell *cell =(XXXCell*)[[sender superview] superview];
NSIndexPath* index=[self.tableview indexPathForCell:cell];
//------
}
本文介绍了如何在UITableViewCell中添加并响应UISwitch的状态变化事件。通过设置target和action,可以在开关状态改变时触发指定的方法,并获取到当前的单元格及位置信息。
634

被折叠的 条评论
为什么被折叠?



