我在UITableView中有一个UISwitch,我想按以下方式传递事件,但事件是nil。如果我已经替换了按钮的开关,事件将存在
[switch addTarget:self action:@selector(switchTaped:event:) forControlEvents:UIControlEventValueChanged];
-(void)switchTaped:(id)sender event:(id)event {
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:_tableView];
NSIndexPath *indexPath= [_tableView
indexPathForRowAtPoint:currentTouchPosition];
NSLog(@"%ld",indexPath.row);
}