use*_*723 0 iphone xcode objective-c
是否可以区分uitableview中哪一行被点击?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//which side of row has been detected left or right
}
Run Code Online (Sandbox Code Playgroud)
您可以继承UITableViewCell.在您的子类中,您可以创建一个iVar wasTouchOnLeft.然后覆盖touchesBegan或touchesEnded类似下面的示例:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=(UITouch *)[touches anyObject];
if([touch locationInView:self].x< (0.5 * self.frame.size.width) )
{
NSLog(@"Touched Left");
wasTouchOnLeft=YES;
}
else {
NSLog(@"Touched Right");
wasTouchOnLeft=NO;
}
[super touchesEnded:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
在didSelectRowAtIndexPath你的UITableViewController你就可以访问该wasTouchOnLeft变量的单元格.
| 归档时间: |
|
| 查看次数: |
819 次 |
| 最近记录: |