UITapGestureRecognizer nicht mit meiner UIImageView Klasse auf meinem UIViewController arbeiten.UITapGestureRecognizer nicht mit UIImageView Individueller Klasse arbeitet
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
Warum funktioniert es nicht möglich, ein Ereignis zu haben, während userInteractionEnabled Formularansichten Eltern aktiviert werden?
Vielen Dank für Ihre Hilfe :)
Fehlende 'self.userInteractionEnabled = YES;' in 'init'? – Larme
@Larme userInteractionEnabled ist standardmäßig YES. –
Nicht auf 'UIImageView', oder das ist neu. – Larme