【问题标题】:How to change UIbutton title once a UIbutton is pressed?按下 UIbutton 后如何更改 UIbutton 标题?
【发布时间】:2012-02-16 12:22:10
【问题描述】:

按下 btn1 后,我无法更改 UIButton btn2 的标题。当我使用_definition settitle:@"Show Word" forState: UIControlStateNormal 时,它会更改原来的 btn1。

这是供您查看的代码,

- (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


【解决方案1】:

尝试以下方式:

[btn2 setTitle:@"Show Word"]

【讨论】:

    【解决方案2】:

    你可以试试这个方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 1970-01-01
      • 2014-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多