Amit Raz
Amit Raz

Reputation: 5534

change UIButton title programmatically

I want to toggle the text of a button based on clicks - every time the button is clicked the title will change from textA to TextB and so on. but when I use button.titlelabel.text = @"blabla" but the text stays the same.

Upvotes: 3

Views: 1849

Answers (2)

visakh7
visakh7

Reputation: 26400

This is worth a try:

-(IBAction)buttonClickEvent 
{
   [button setTitle:@"your title" forState:UIControlStateNormal];
}

Upvotes: 9

Nyx0uf
Nyx0uf

Reputation: 4649

- (void)setTitle:(NSString *)title forState:(UIControlState)state

Upvotes: 2

Related Questions