xcode – [IOS SDK] – touchesBegan与特定对象?

xcode – [IOS SDK] – touchesBegan与特定对象?,第1张

概述当我触摸屏幕上的任何地方触摸触发事件时触发.但我无法管理如何像UI ImageView一样触摸特定对象? -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch lo 当我触摸屏幕上的任何地方触摸触发事件时触发.但我无法管理如何像UI ImageVIEw一样触摸特定对象?

-(voID)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UItouch *touch = [[event alltouches] anyObject]; CGPoint location = [touch locationInVIEw: touch.vIEw]; imageVIEw.center = location;}-(voID)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self touchesBegan:touches withEvent:event];}
解决方法 好的,找到了解决方案,这里是代码:

-(voID)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {    UItouch *touch = [[event alltouches] anyObject];    if ([touch vIEw] == imageVIEw) {        CGPoint location = [touch locationInVIEw: self.vIEw];        imageVIEw.center = location;    }}
总结

以上是内存溢出为你收集整理的xcode – [IOS SDK] – touchesBegan与特定对象?全部内容,希望文章能够帮你解决xcode – [IOS SDK] – touchesBegan与特定对象?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1002570.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存