触摸哪个物体
这对你来说可能看起来很简单,但我想知道视图上正在触摸哪个对象...
我解释...在 viewDidLoad 方法中,我有几个以编程方式创建的对象(uiimageviews、标签、按钮等) 。
现在在touchesEnded方法中,我想知道哪个对象被单击了......如何?
我尝试了 [touch self] == UIImageView],但它不起作用......
谢谢
This may seems simple for you but I would like to know which object is being touched on a view...
I explain...in the viewDidLoad method, I have several objects which are created programmatically (uiimageviews, labels, buttons, etc).
Now in the touchesEnded method, I would like to know which object has been single tapped...how to?
I tried [touch self] == UIImageView], but it's not working...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
回调提供您需要touches
参数的信息。要提取获得触摸的视图,请使用:然后您可以进行比较:
更多信息位于 developer.apple.com
The
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
callback provides the information you need thetouches
parameter. To extract the view that got the touch use:You can then compare:
More info at developer.apple.com