ios怎么判断我点击的哪个视图
展开全部
您好,很高兴为您解答。
你的意思是两个view,通过点击手势进行判断,如果是这样,设置tag来区分
view1.tag = 1;
<br>
<br> UITapGestureRecognizer *tapGestureRecognizer1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
<br>
<br> [view1 addGestureRecognizer:tapGestureRecognizer];
<br>
<br>
<br>
<br> view2.tag = 2;
<br>
<br> UITapGestureRecognizer *tapGestureRecognizer2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
<br>
<br> [view2 addGestureRecognizer:tapGestureRecognizer2];
<br>
<br>
<br>
<br>- (void)tapped:(UITapGestureRecognizer *)gesture
<br>
<br>{
<br>
<br> UIView *targetview = gesture.view;
<br>
<br> if(targetview.tag == 1) {
<br>
<br>
<br>
<br> }
<br>
<br>}
如若满意,请点击右侧【采纳答案】,如若还有问题,请点击【追问】
希望我的回答对您有所帮助,望采纳!
~ O(∩_∩)O~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |