How to change UIbutton title once a UIbutton is pressed?

[亡魂溺海] 提交于 2020-01-11 12:13:12

问题


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

}

回答1:


Try something along the lines of:

[btn2 setTitle:@"Show Word"]



回答2:


u can try this way:

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


来源:https://stackoverflow.com/questions/8966769/how-to-change-uibutton-title-once-a-uibutton-is-pressed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!