In my program, I want the image in the scroll view can be detected when there is a touch. I had read the internet that there are some codes that can help to solve the problem
In a subclass .h file:
@interface AllScrollView : UIScrollView
{
}
@end
In the subclass .m file:
#import "AllScrollView.h"
@implementation AllScrollView
- (id)initWithFrame:(CGRect)frame
{
return [super initWithFrame:frame];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
if (!self.dragging)
[self.nextResponder touchesEnded: touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
@end
and then I change the method - (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event on the main class. However, there is nothing happened and I cannot detect the touch. Do I miss something ? Could anyone give a more detail solution ? Thank you so much!
I used Gesture Recognizers with a scroll view, and they work fine. In your case, I would select a single tap recognizer, like this: