How do you tell what object is being touched in touchesBegan?

后端 未结 1 1157
悲&欢浪女
悲&欢浪女 2021-02-13 00:52

I know that this is a very commonly asked question, but all of the answers on every website don\'t work! If you still don\'t know what I mean, then maybe this line of code will

1条回答
  •  [愿得一人]
    2021-02-13 01:47

    You have to set userinteractionEnabled = YES for all your UIImageViews otherwise they will not receive touch events. Also change the line:

     UITouch *touch = [[event allTouches] anyObject];
    

    to

     UITouch *touch = [touches anyObject];
    

    0 讨论(0)
提交回复
热议问题