UITapGestureRecognizer не работает с моим классом UIImageView на моем UIViewController.UITapGestureRecognizer не работает с UIImageView Пользовательский класс
HousePictureView *pictureHouse = [[HousePictureView alloc] init:[dictionary objectForKey:@"photo_url"]];
UITapGestureRecognizer *picturestap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showpictures)];
picturestap.numberOfTapsRequired = 1;
[pictureHouse addGestureRecognizer:picturestap];
[parentScroll addSubview:pictureHouse];
HousePictureView.m
@interface HousePictureView() {
CGFloat screenwidth;
}
@property (strong, nonatomic) UIImageView *pictureView;
@end
@implementation HousePictureView
-(id)init:(NSString*)url
{
screenwidth = [UIScreen mainScreen].bounds.size.width; // Width of this screen
if(self = [super init])
{
_pictureView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,screenwidth,300)];
[_pictureView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[Functions resizeImage:[UIImage imageNamed:@"nophoto"] newSize:CGSizeMake(screenwidth,300)]];
_pictureView.userInteractionEnabled = YES;
[self addSubview:_pictureView];
}
return self;
}
@end
HousePictureView.h
@interface HousePictureView : UIImageView
- (id)init:(NSString*)url;
@end
Почему это не возможно иметь событие в то время как просмотр userInteractionEnabled форма родители активируются?
Спасибо за вашу помощь :)
Отсутствует 'self.userInteractionEnabled = YES;' в 'init'? – Larme
@Larme userInteractionEnabled - ДА по умолчанию. –
Не на 'UIImageView', или что нового. – Larme