I have four ImageViews of equal heights and widths which fill up the screen in my iPhone Application and i need to drag and reposition all views using uipangesturerecogniser. I have added the necessary constraints to all the views such as equal heights for all and each views are connected to each other. Since each view connected to each other was a problem because if i drag one others also move. Hence, all views top are connected to top of the view and constant was changed when dragged as mentioned in link iOS >> Dragged View is Jumping Back to Original Position >> Auto Layout Combined with UIPanGestureRecognizer Issue. But when i drag one view and move another, the old views goes back to initial position. Hence, the problem is that i have tried many things and i have to maintain equal heights for all and should be able to drag and reposition all of them. Can some please help me with this issue?
Thank you
code:
func toppangesture(panGesture1:UIPanGestureRecognizer)
{
let loc=panGesture1.translation(in: self.view)
var diff:Float
if (panGesture1.state.rawValue==2)
{
let val=Float(loc.y)
diff=Float(val) - Float((prevValue1?.y)!)
let yval=CGFloat(diff)
self.topimgyconstraint?.constant+=yval
self.topimg.frame.origin.y+=yval
self.view.layoutIfNeeded()
prevValue1=loc;
}
else if (panGesture1.state.rawValue==1)
{ self.prevValue1=loc
}
}