How to change UIbutton title once a UIbutton is pr

2020-04-18 05:30发布

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);

}

标签: ios5 uibutton
2条回答
Animai°情兽
2楼-- · 2020-04-18 05:55

u can try this way:

[_definitionPressed setTitle:@"Normal State" forState:UIControlStateNormal];
[_definitionPressed setTitle:@"Selected State" forState:UIControlStateHighlighted];
查看更多
家丑人穷心不美
3楼-- · 2020-04-18 05:58

Try something along the lines of:

[btn2 setTitle:@"Show Word"]
查看更多
登录 后发表回答