Sunday, March 17, 2013

How to create a button click event handler


  1. Open story board.
  2. Drag a button (Round Rect Button) on the screen, the default text would be "Button". Let it be.
  3. Open ViewController.h and add the following code in the @interface section:

    -(IBAction)btnClicked:(UIButton *)sender;

  4. Open ViewController.m and add the following code in the @implementation section:

    -(IBAction) btnClicked:(UIButton *)sender
    {
        //Write your event handler code here    
    }

  5. Open story board.
  6. Right click-drag from the button to the yellow View Controller icon.

  7. A popup will appear with some choices, at the end you will find btnClicked, select it. 
  8. Done

No comments:

Post a Comment