I'm trying to create a button which will trigger an action when the user's touch is brought anywhere into the button (whether they touch down inside, or drag from outside to inside the button). Essentially, I need to create a way to trigger the action whenever a finger is inside of the button.
"Touch drag enter" combined with "touch down inside" sounds like it would do the job, but it seems to be working differently than what I need.
Also, I'd prefer if it can be done in storyboard rather than hard code (like touchesBegan/moved), but if there is no other way that's okay.
Touch drag enter
will only gets called, when u start the touch inside the control and drag it outside the bounds of the control and then drag it back inside the control, without leaving the touch. So you need to subclass your button and achieve the required functionality.
Either you will have to bind all the events one by one with the method you are intending to invoke on button press from IB.
OR
You can try register your button for UIControlEventAllTouchEvents
inside your code. Here is an example that might be helpful
[_btnRoundRect addTarget:self action:@selector(btnPressedAction) forControlEvents:UIControlEventAllTouchEvents];
- (void)btnPressedAction{
NSLog(@"Bttn pressed");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With