Interface Builder - Event on UIButton?

Discussion in 'iOS Programming' started by newdev, Aug 5, 2008.

  1. macrumors newbie

    Joined:
    Aug 5, 2008
    #1
    Alright... my first post here and I am pretty stuck :(

    I create a simple UI using IB..

    I have a tabbar .. which loads its view from an external xib file. in this external xib file i have the file's owner as a custom UIViewController class.. and inside I dragged a UIView .. now so far everything works fine.. when i run it in simulator i can see the view loaded and everything

    Now i wanted to add a UIButton to the UIView and handle the "event" on the UIButton in the UIViewController class..

    any idea how an i do it?

    when I create an IBOutlet UIButton* button; in my UIViewController class it crashes on me.. how can i do this then?

    any tips?

    thanks
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Setup an IBAction method, and then in IB control-click from your button to File's Owner (or whatever object in the NIB represents your view controller) and select your method. This method will get called whenever your button is clicked.
     

Share This Page