ios - Drag and Drop uimageview restrict drop area -


i want implement drag , drop functionality in application.this requirement, have 5 small images , 1 big image in view controller.i need place small images on big image.the big image in particular size.

when small image dragged , not place on over big image backs original place.

when small image placed on big image cannot original place can draggable big image space.

can me?i can found lot of tutorials none satisfied.

i want image dropped in big image space.but not outside of imageview.

please me!

thank you!

as others have said, you're question broad.

i suggest subclassing uiview , using uipangesturerecognizer detect grab, move views.

when view released call function check objects location respect other views , swap views accordingly animations. if view within range of it's origin snaps animation.

your uiview subclass this:

@interface draggableview () <uigesturerecognizerdelegate>  @property (nonatomic) float originx;  @end  @implementation draggableview  -(id)initwithframe:(cgrect)frame {     self = [self initwithframe:frame];      uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(touched:)];     [pan setminimumnumberoftouches:1];[pan setmaximumnumberoftouches:1];     [pan setdelegate:self];     [self addgesturerecognizer:pan];       return self; }  - (void) touched:(id)sender {      cgpoint translatedpoint = [(uipangesturerecognizer*)sender translationinview:self.superview];      if([(uipangesturerecognizer*)sender state] == uigesturerecognizerstatebegan) {          self.originx = [[sender view] center].x;      }     else {          translatedpoint = cgpointmake(self.originx+translatedpoint.x, self.center.y);                 [[sender view] setcenter:translatedpoint];      }      if([(uipangesturerecognizer*)sender state] == uigesturerecognizerstateended)     {          // check if view should swap or bounce      }  } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -