触摸开始于特定对象
我一直在谷歌上搜索,但没有找到任何答案。
我想在特定对象上使用 TouchesBegan,例如文本视图、标签...... 我尝试用我的对象的指针替换“任何对象”,但它不起作用。
是否有其他方法可以用某种方法检测物体上的触摸,以便我可以告诉:做某事? ,就像在 TouchsBegan 方法中一样,但是针对特定对象?
提前感谢您的回答/或者示例代码会很棒;o)祝您
有美好的一天! 罗宾
I've been searching on google for that , but didn't found any answer.
I want to use TouchesBegan but on a specific object, like a textview, a label, ...
I've tried to replace "any object" by the pointer of my object but it doesn't work.
Is there on other way to detect the touch on a object with a method , in witch I can tell after : do something ? , like in the touchesbegan method but for a specific object ?
Thank you in advance for your answers / or sample code would be great ;o)
Have a nice day !
Robin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过
CGRectMake()
在该区域上创建CGRect
,然后检查触摸是否在该区域内 - 然后执行您的操作。Make
CGRect
byCGRectMake()
on that area and then check, if touch is within that area - then do your things.我不确定我是否完全理解您的要求,但是如果您对要检测触摸的对象类进行子类化并向该类添加 TouchBegan 方法,则只有当其所属的对象被触摸时才会触发它。我相信这就是您正在寻找的。
或者你问的是不同的东西?
霍华德
I'm not sure I understand exactly what you're asking, but if you subclass the class of object you want to detect touches on and add a touchesBegan method to that class, it will only get triggered when the object it belongs to is touched. Which I believe is what you're looking for.
Or are you asking something different?
Howard