objective c - UILabel: adding 1 to a number when button pressed? -
i new this, on how change uilabel add 1 previous number, everytime button pressed. i.e want when press button uilabel turns 0 1, , if press again turns 1 2. appreciated. in advanced. know have create button, don't know code put in their?
do this
//header @property (nonatomic) int i; - (ibaction)buttonclicked:(uibutton *)sender; //implementation - (void)viewwillappear{ self.i = 0; } - (ibaction)buttonclicked:(uibutton *)sender{ self.i++; [self.textfield settext:[nsstring stringwithformat:@"%d", self.i]]; }
self.textfield
whatever text area want display number in. also, have make connection buttonclicked
action button in interface builder, if you're using it.
Comments
Post a Comment