objective c - change the text to uibutton in iOS -
i have mistake change text uibutton in ios
@interface viewcontrollersonidos : uiviewcontroller{ __weak iboutlet uibutton *initgame; } @property (weak, nonatomic) iboutlet uibutton *initgame; - (ibaction)reproducir:(id)sender;
and implementation file looks this:
@implementation viewcontrollersonidos @synthesize initgame - (ibaction)reproducir:(id)sender { [initgame settitle:@"continue" forstate:uicontrolstatenormal]; }
but problem text never changed, looks wrong? in advance!
you have many ways can this.
- you can connect iboutlet,
- you can use id sender
- or use simple ibaction signature
examples:
// using id sender method - (ibaction) buttontitlechange:(id)sender { [sender settitle: @"title" forstate:uicontrolstatenormal]; } // using connection 1 - (ibaction) buttontitlechange: (id)sender { //after connecting button in .xib [buttonname settitle:@"title" forstate:uicontrolstatenormal]; } // , regular void method....also requiring linkage of .xib - (ibaction) buttontitlechange { [buttonname settitle:@"title" forstate:uicontrolstatenormal]; }
just remember connect button in .xib them all
using id sender, says can use type object. id sender connection way of writing method, , regular method way of practice.
it depends on how program.
hope helps!
Comments
Post a Comment