DETECTING EVENTS ON TAP OF UIBUTTON IN IOS

Linda Perla

Total Post:13

Points:93
Posted by  Linda Perla
 619  View(s)
Ratings:
Rate this:

In my iPhone application on which I am working I want to handle an event occurs when UIButton touch is ended.
I know that UIControl has some events implementing touches (UIControlEventTouchDown, UIControlEventTouchCancel, etc.).
But my problem is I am unable to catch any of them except UIControlEventTouchDown and UIControlEventTouchUpInside.

My button is a subview of another UIView. That UIView has userInteractionEnabled property set to YES.
I am unable to understand that what's wrong I am doing?

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Detecting events on tap of UIButton in iOS

    There are many ways to identify button event here I am providing one of them:
    set 'action targets' according to your ControlEvents, like this:

    [buttonName addTarget:self action:@selector(methodTouchDown:)

    forControlEvents:UIControlEventTouchDown];

    Here is MethodTouchDown declaration:

    -(void)MethodTouchUpInside:(id)sender{
     NSLog(@"Button is Clicked");
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!