Reputation: 3048
I have four UIButtons in my interface file. I have outlets attached to each button. I want to be able to drag and drop them across the screen. What is the best way to do this? How can I do this? please help!!!
Upvotes: 1
Views: 1923
Reputation: 1415
try this u can drag and drop your button what ever you want
implement this code in ViewDidLoad
[self.shoeimageOutlet addTarget:self action:@selector(imageMoved:withEvent:) forControlEvents:UIControlEventTouchDragInside];
[self.shoeimageOutlet addTarget:self action:@selector(imageMoved:withEvent:) forControlEvents:UIControlEventTouchDragOutside];
it will call the method written below
- (IBAction) imageMoved:(id) sender withEvent:(UIEvent *) event
{
CGPoint point = [[[event allTouches] anyObject] locationInView:self.view];
UIControl *control = sender;
control.center = point;
}
Upvotes: 1
Reputation: 915
There are 3 possibilities nowadays on how to enable items – that is UIViews and UIControls – to be draggable.
The complete tutorial found here !!!
Upvotes: 0