Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa touch 使用子视图接触视图_Cocoa Touch_Uiview_Touch - Fatal编程技术网

Cocoa touch 使用子视图接触视图

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

我想要一个俯视图(UIView的子类),它可以用

- (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
}