Question

I am creating a semi-piano app in Objective-C for iPhone; it's in fact a diffrent layout MIDI Controller, but I'm still working on the design.

I created all of the "keys" with UIButtons, and I want to be able to slide to them or from them to other UIButtons.

I read all the similar questions before, but I couldn't make it to work with touchesMoved, Because it only worked from the view if I didn't drag the finger from a UIButton.

Thanks in advance, code will be appreciated!

Était-ce utile?

La solution

Are your buttons created in IB? The default event when connecting buttons in IB is "touch up inside", which means the action is fired when the user ends a touch (lifts the finger) inside the button. A piano key or similar would be more appropriate to fire on the "touch down inside" (for the initial press) and the "touch drag enter" (for when a finger that is already on the screen moves into the button).

Since you are doing it programmatically, you can add targets to the buttons as described here:

http://developer.apple.com/library/ios/documentation/uikit/reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/instm/UIControl/addTarget:action:forControlEvents:

Just include the events you want in the mask.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top