iphone - Simulate cursor and click -
i want simulate mouse pointer , click event on object in view. until able simulate mouse pointer i.e. mouse pointer moves dragging on view. want fire tap event on underlying object on simulated mouse pointer clicked. suppose button. concept finger mouse.
i got you,
1) add uitapgesturerecognizer
mouse pointer.
2) in tapgesture handle method,
get finger point,
cgpoint fingerlocation = [tap locationinview:self.view];
make fingerrect this,
cgrect finderrect = cgrectmake(location.x - 5, location.y - 5, 10, 10);
iterate through uiviews in self.view
(uiview *view in self.view.subviews) { cgrect frameoftheview = view.frame; if(cgrectintersectsrect(frameoftheview, finderrect)){ nslog(@"clicked on view %@", view); return; } }
finally method this,
-(void) handletap:(uitapgesturerecognizer *) tap{ //get tapped point cgpoint location = [tap locationinview:self.view]; cgrect finderrect = cgrectmake(location.x - 5, location.y - 5, 10, 10); (uiview *view in self.view.subviews) { cgrect frameoftheview = view.frame; if(cgrectintersectsrect(frameoftheview, finderrect)){ nslog(@"clicked on view %@", view); return; } } }
that way can detect touched view, depending on view can call methods want.