objective c - ios locationInView not show correct log when I click direct view -


i feel strange, have dark view(darkscreenview) , green view.

i using

 -(void) touchesbegan:(nsset *)touches withevent:(uievent *)event  {      uitouch *touch = [[event alltouches] anyobject];      cgpoint touchviewpoint = [touch locationinview:touch.view];        nslog(@"[self.darkscreenview pointinside:touchviewpoint withevent:event]:%d",[self.darkview pointinside:touchviewpoint withevent:event]);  } 

when click on dark view or green view,

the log still show 1. why?

i click on green view should show log 0, still log result 1.

enter image description here

enter image description here

i using xcode 6.3.1.

have know problem in situation?

thank you~

this work

uitouch *touch = [[event alltouches] anyobject];     cgpoint touchviewpoint = [touch locationinview:touch.view];     cgpoint  pointofdarkview = [touch.view convertpoint:touchviewpoint toview:self.darkview];     nslog(@"[self.darkscreenview pointinside:touchviewpoint withevent:event]:%d",[self.darkview pointinside:pointofdarkview withevent:event]); 

your problem:

touchviewpoint relative touch.view coordinate

you have convert point darkview coordinate first,then can use pointinside:pointofdarkview


Comments