类似iPad钢琴的应用程序帮助!
我正在编写一个类似 iPad 钢琴的应用程序。我首先通过 UIButton 创建按键,一切正常,但是当我想从一个键滑动到另一个键时,我发现这是一个拖出操作(第一个按钮的)而不是触摸操作(第二个按钮的) 所以只是想知道是否有人知道有什么方法可以禁用 UIbutton 的拖动或任何其他更好的方法来进行滑动?
I am writing an iPad piano-like app. I firstly created the keys by UIButton, everything worked fine but when I want to slide from one key to another I found that it's a drag-out action (of the first button) rather than touch down action (of the second button)
so Just wondering does anyone know any ways to disable the dragging of UIbutton or any other better way to do that sliding ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
非常老的问题,但是当我现在正在研究这个问题时......当我开始实现钢琴键盘时,我只是使用了键盘的大图像,并找出了控制器中按下的键
touchesBegan< /code>、
touchesMoved
方法。然后,当我想添加按键效果时,我认为 UIButton 会很好用。不幸的是,我遇到了与您相同的问题:第一个UIButton
键按下“捕获”触摸,然后其他键就无法使用该触摸。我认为最简单的解决方案是回到原始控制器
touchesBegan
、touchesMoved
方法。我会将所有UIButton
更改为UIImageView
,并从控制器进行触摸检测和按键动画。Very old question, but as I'm working on this now... When I started implementing a piano keyboard, I simply used a big image of the keyboard, and worked out what key was being pressed in my controllers
touchesBegan
,touchesMoved
methods. Then, when I wanted to add key press effects, I thoughtUIButton
s would work well. Unfortunately, I ran into the same problem you have: the firstUIButton
key pressed "captures" the touch, which is then not available to the other keys.The simplest solution, I think, is to go back to the original controller
touchesBegan
,touchesMoved
method. I will change all myUIButton
s intoUIImageView
s, and do touch detection and key animation from the controller.