I am making a book application and i used UIScrollView for paging. Everything is going pretty well but when i started coding the function for drag and drop Images it’s not working, but the code works in my other projects without the UIScrollView.
Is it possible to apply drag and drop functionality on a UIScrollView?
here’s my code
image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image1.png"]];
[image1 setFrame:CGRectMake(2834, 225, 150, 184)];
[scrollPaging addSubview:image1];
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.view];
image1.center = location;
}
The trick is to disable scrolling on the scrollview when you detect that you are starting to drag an item (I use a delayed selector to determine a start drag operation), and re-enable scrolling once you release the touch.
To disable scrolling use…