user2326633
user2326633

Reputation: 33

How to make a uibutton with touch down action and touch up inside action

I need to make one button with two actions, touch down used to play a sound and then touch up inside to stop playing the sound when you let go of the button

Upvotes: 1

Views: 2513

Answers (1)

mayuur
mayuur

Reputation: 4746

Connect two methods to both these actions.

[self.yourBtn addTarget:self action:@selector(touchDownMethod:) forControlEvents:UIControlEventTouchDown];
[self.yourBtn addTarget:self action:@selector(touchUpInsideMethod:) forControlEvents:UIControlEventTouchUpInside];

Upvotes: 4

Related Questions