Can you attach a UIGestureRecognizer to multiple views?

前端 未结 12 1025
忘了有多久
忘了有多久 2020-11-22 14:08
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)];
[self.view1 addGestureRecognizer:tapGesture];         


        
12条回答
  •  青春惊慌失措
    2020-11-22 15:08

    if you have fixed view I suggest you doing something like this

    [self.view1 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)]];
    [self.view2 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)]];
    

    that way will reduce multiple different useless variable

提交回复
热议问题