James Barron
James Barron

Reputation: 11

How to change UIbutton title once a UIbutton is pressed?

I am having trouble changing the title of UIButton btn2 once btn1 is pressed. When I use _definition settitle:@"Show Word" forState: UIControlStateNormal it changes the original btn1.

Here is the code for your review,

- (IBAction)mynextPressed:(UIButton *)sender {

    //Display the string in the label field

    [self.WordDisplay setText:vocabulary];

    //reset center button with "show word"
    [_definitionPressed setTitle:@"Show Word" forState:UIControlStateNormal];
    NSLog(@"displaying word: %@", _definitionPressed.titleLabel);

}

Upvotes: 1

Views: 3006

Answers (2)

Banker Mittal
Banker Mittal

Reputation: 1918

u can try this way:

[_definitionPressed setTitle:@"Normal State" forState:UIControlStateNormal];
[_definitionPressed setTitle:@"Selected State" forState:UIControlStateHighlighted];

Upvotes: 0

CSturgess
CSturgess

Reputation: 1557

Try something along the lines of:

[btn2 setTitle:@"Show Word"]

Upvotes: 1

Related Questions