By default UIImageView
has userInteractionEnabled
is false
Set the property userInteractionEnabled= YES
Try this,
@implementation MjpegView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
if (_endMarkerData == nil) {
uint8_t endMarker[2] = END_MARKER_BYTES;
_endMarkerData = [[NSData alloc] initWithBytes:endMarker length:2];
}
self.contentMode = UIViewContentModeScaleAspectFit;
self.userInteractionEnabled=YES;
singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSingleTap:)];
singleTapRecognizer.numberOfTapsRequired = 1;
singleTapRecognizer.numberOfTouchesRequired = 1;
[self addGestureRecognizer:singleTapRecognizer];
[[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:_url] delegate:self];
}
return self;
}