/ / UIGestureRecognizer no Objective-C ++ - ios, iphone, object-c ++

UIGestureRecognizer no Objective-C ++ - ios, iphone, object-c ++

Eu quero conhecer o UIGestureRecognizer trabalhando ou não em Objective-C ++ porque eu tenho implementado este, mas toque método nunca chamando. Então, por favor, deixe-me saber é possível ou não em Objective-C + +.

        - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
imgView.image = [UIImage imageNamed:@"dharm"];
[self.view addSubview:imgView];
imgView.backgroundColor = [UIColor redColor];

UITapGestureRecognizer* tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
tapRecognizer.numberOfTapsRequired = 1;
[tapRecognizer setDelegate:self];
[imgView addGestureRecognizer:tapRecognizer];
}
- (void)tap:(id)sender {
NSLog(@"Tap Pressed");
}

Respostas:

1 para resposta № 1

Tente adicionar [imgView setUserInteractionEnabled:YES];