iphone - touchesbegan with multiple UIImageView detects incorrect UIImageView -
i'm having problem touch detection on ipad.
i subclassed uiimageview this:
@interface myuiimageview : uiimageview { bool _dragactive; cgpoint originallocation; } @end @implementation myuiimageview - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { _dragactive = yes; originallocation = self.center; } - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { if (_dragactive) { uitouch* touch = [touches anyobject]; self.center = [touch locationinview:self.superview]; } } - (void)touchesended:(nsset *)touches withevent:(uievent *)event { if (_dragactive) { self.center = originallocation; } _dragactive = no; } - (void)touchescancelled:(nsset *)touches withevent:(uievent *)event { if (_dragactive) { self.center = originallocation; } _dragactive = no; } @end
i have multiple imageview(myuiimageview) controls on controller view side side touchesbegan being called front although separated on controller view.
looks there invisible "detection layer" spawns beyond imageviews.
when click , drag imageview 1 dragged 1 left or right depending on 1 in front. if change z axis behavior repeats on images on front.
i m not getting clear idea of exact requirement.if want touches detected particular imageview (i.e imageview @ leftmost or rightmost) try assing object uitouch instead of using anyobject ->
uitouch* touch = [touches anyobject];
use way if works uitouch* touch = [touches imgviewobject];
Comments
Post a Comment