Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/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
Iphone CAShapeLayer hitTest触控_Iphone_Uikit_Core Graphics_Quartz Graphics_Cashapelayer - Fatal编程技术网

Iphone CAShapeLayer hitTest触控

Iphone CAShapeLayer hitTest触控,iphone,uikit,core-graphics,quartz-graphics,cashapelayer,Iphone,Uikit,Core Graphics,Quartz Graphics,Cashapelayer,我不明白为什么现金支付者对hitTest没有反应 此功能始终转到//触摸在外部 我如何检测到触摸到一个自动售货机 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { currentPoint = [[touches anyObject] locationInView:self]; for (CAShapeLayer *layer in self.layer.sublayers) {

我不明白为什么现金支付者对hitTest没有反应

此功能始终转到//触摸在外部

我如何检测到触摸到一个自动售货机

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { currentPoint = [[touches anyObject] locationInView:self]; for (CAShapeLayer *layer in self.layer.sublayers) { if(layer == shapeLayer) { if([layer hitTest:currentPoint]) { // touche is on the layer } else { // touche is outside } } } } -(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件 { currentPoint=[[Touchs anyObject]locationInView:self]; 对于(self.layer.sublayers中的CAShapeLayer*层){ 如果(图层==shapeLayer){ 如果([层命中测试:currentPoint]) { //touch在图层上 } 否则{ //图奇在外面 } } } }
在撞了我的头两天后,我能够产生这个奇怪的代码,看起来它正在工作

目标是击中测试层。CAShapeLayer在屏幕上移动,因此形状不是固定的。测试CGPath currentPoint并不简单

请随意添加任何输入

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint p = [[touches anyObject] locationInView:self]; CGAffineTransform transf = CGAffineTransformMakeTranslation(-shapeLayer.position.x, -shapeLayer.position.y); if(CGPathContainsPoint(shapeLayer.path, &transf, p, NO)){ // the touch is inside the shape } } -(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件 { CGPoint=[[toucheanyobject]locationInView:self]; CGAffineTransform transf=CGAffineTransformMakeTransform(-shapeLayer.position.x,-shapeLayer.position.y); if(CGPathContainsPoint(shapeLayer.path,&transf,p,NO)){ //触摸在形状内部 } }
在撞了我的头两天后,我能够产生这个奇怪的代码,看起来它正在工作

目标是击中测试层。CAShapeLayer在屏幕上移动,因此形状不是固定的。测试CGPath currentPoint并不简单

请随意添加任何输入

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint p = [[touches anyObject] locationInView:self]; CGAffineTransform transf = CGAffineTransformMakeTranslation(-shapeLayer.position.x, -shapeLayer.position.y); if(CGPathContainsPoint(shapeLayer.path, &transf, p, NO)){ // the touch is inside the shape } } -(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件 { CGPoint=[[toucheanyobject]locationInView:self]; CGAffineTransform transf=CGAffineTransformMakeTransform(-shapeLayer.position.x,-shapeLayer.position.y); if(CGPathContainsPoint(shapeLayer.path,&transf,p,NO)){ //触摸在形状内部 } }
请参见下文-重写cashapetest()方法


请参见下文-重写cashapetest()方法