Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 923
Amit Raz Avatar asked Sep 03 '26 19:09

Amit Raz


2 Answers

This is worth a try:

-(IBAction)buttonClickEvent 
{
   [button setTitle:@"your title" forState:UIControlStateNormal];
}
like image 74
visakh7 Avatar answered Sep 05 '26 11:09

visakh7


- (void)setTitle:(NSString *)title forState:(UIControlState)state
like image 30
Nyx0uf Avatar answered Sep 05 '26 09:09

Nyx0uf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!