iphone - Translate UIView by dragging another UIView -


please refer image below following question: blue , orange circles see uiview's. able drag blue uiview has uipangesturerecognizer , have orange circle translate accordingly , stay same distance blue circle now. meaning, if drag blue circle down, orange uiview should stay parallel blue circle , translate down well. if drag blue circle right, orange circle should translate right , stay same distance blue circle now.

image

so right circles part of same class have uipangesturerecognizer on them. here code drag these views:

-(void)dragging:(uipangesturerecognizer *)p {   uiview *newview = p.view; if (p.state == uigesturerecognizerstatebegan) {     self.origc = newview.center; } self.delta = [p translationinview:newview.superview]; cgpoint c = self.origc;  c.x +=self.delta.x; c.y +=self.delta.y;  newview.center = c;  [self.delegate refreshview]; } 

within uipangesturerecognizer class, able obtain translation of pan gesture in coordinate system of specified view with:

self.delta = [p translationinview:newview.superview];

i think delta need apply translation of orange circle, i'm not sure how go doing that? appreciated. thank you!

do doing directly dragged point.

if (p.state == uigesturerecognizerstatebegan) {     self.origc = newview.center; // code     self.origd = otherview.center; // new code } cgpoint c = self.origc; // code c.x +=self.delta.x; // code c.y +=self.delta.y; // code newview.center = c; // code cgpoint d = self.origd; // new code d.x +=self.delta.x; // new code d.y +=self.delta.y; // new code otherview.center = d; // new code 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -