I am having one view in ipad. On that view , I am having four buttons. Now when I click on that button , one view is opening with some fixed height,width,x position and y position. I want to make this new view dock-able. I mean I want to drag this view to anywhere on that big view.
Asked
Active
Viewed 87 times
2 Answers
0
You can optimize this in your situation..
-(void)dragging:(UIPanGestureRecognizer *)gesture
{
if(gesture.state == UIGestureRecognizerStateBegan)
{
//NSLog(@"Received a pan gesture");
self.panCoord = [gesture locationInView:gesture.view];
}
CGPoint newCoord = [gesture locationInView:gesture.view];
float dX = newCoord.x-panCoord.x;
float dY = newCoord.y-panCoord.y;
gesture.view.frame = CGRectMake(gesture.view.frame.origin.x+dX, gesture.view.frame.origin.y+dY, gesture.view.frame.size.width, gesture.view.frame.size.height);
}