I am developing an app in which I have to drag UIImageview from UIScrollview. At the bottom part of my main UIView, I've an UIScrollView with UIImageViews inside. I have created custom UIScrollview using following code snippet:
@interface CustomScroll : UIScrollView {
}@end
@implementation CustomScroll
- (id)initWithFrame:(CGRect)frame {
return [super initWithFrame:frame];
}
- (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging) {
self.scrollEnabled=NO;
[self.nextResponder touchesMoved:touches withEvent:event];
}
else{
[super touchesMoved: touches withEvent: event];
}
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging)
[self.nextResponder touchesEnded: touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
@end
From here I have included a CustomScroll object in my PuzzleViewController and connect it to the scrollview of Interface builder:
@interface PuzzleViewController : UIViewController <UIScrollViewDelegate> {
IBOutlet CustomScroll *segmentScrollview;
}
I've added all UIImageviews programmatically.
This code is working as expected. UIImageview detecting touch and I can drag UIImageview from UIScrollview to UIView.
But problem occurs when I drag UIImageview diagonally.
In my app when I drag UIImageview vertically from scrollview I'm able to move my UIImageView from the UIScrollView to the UIView. But when I drag UIImageview diagonally from scrollview I can not move UIImageview. Diagonal swipe scrolls UIScrollview [UIImageview remains untouched] which is unexpected. I want UIImageview should be drag diagonally from UIScrollview.
Any help would be greatly appreciated.
Thanks in advance for any help.