Cocoa touch 使用子视图接触视图
我想要一个俯视图(UIView的子类),它可以用Cocoa touch 使用子视图接触视图,cocoa-touch,uiview,touch,Cocoa Touch,Uiview,Touch,我想要一个俯视图(UIView的子类),它可以用 - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event ... h 如果不触发XView中的触摸方法,则需要对UITableView进行子类化,或者使用UITapGestureRecognitor来解决此问题。我个人会使用UITapGest
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
...
h
如果不触发XView中的触摸方法,则需要对UITableView进行子类化,或者使用UITapGestureRecognitor来解决此问题。我个人会使用UITapGestureRecognitor
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCode:)];
[self.tableView addGestureRecognizer:tap];
然后,您可以在此处操作水龙头:
- (void)tapCode:(UITapGestureRecognizer *)recognizer
{
// code goes here
}
如果您是UITableView的子类,则可以将touchesbearth:withEvent放在其中
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCode:)];
[self.tableView addGestureRecognizer:tap];
- (void)tapCode:(UITapGestureRecognizer *)recognizer
{
// code goes here
}