我收到以下错误:无法识别的选择器发送到实例并发现很多对我不起作用的解决方案。我从视图类创建对象。我点击图像视图,然后我得到了错误
我有以下代码:
@implementation MyTappableImage
@synthesize myImageView, myRect, isTapped, myTap;
- (id)initWithRect:(CGRect) myRect2
{
myRect = &myRect2;
UIImage *image = [UIImage imageNamed: @"hert.png"];
myImageView = [[UIImageView alloc]initWithFrame:*myRect];
myImageView.userInteractionEnabled = YES;
[myImageView setImage:image];
isTapped = NO;
myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapped:)];
[myImageView addGestureRecognizer:myTap];
return self;
}
-(void)tapped:(UITapGestureRecognizer *)gr {
NSLog(@"druk");
}