ios - 更改 UIButton 的标题不起作用

标签 ios uibutton

我在表格 View 单元格中添加了一个按钮。我的问题是,当我在调用方法 pressHonkBtn:(id)sender 时更改其标题时,它不会更改其标题。

如何解决这个问题。

最佳答案

像这样使用你的代码:

objective-C :

-(IBAction)pressHonkBtn:(id)sender
{
    UIButton *tempBtn = (UIButton *)sender;
    [tempBtn setTitle:@"YOUR_TITLE" forState:UIControlStateNormal];// YOUR_TITLE is your button title
    [tempBtn setTitle:@"YOUR_TITLE" forState:UIControlStateHighlighted];
}

swift :

someUIButton.setTitle("String To Set", forState: UIControlState.Normal)

希望对你有帮助。

关于ios - 更改 UIButton 的标题不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16358670/

相关文章:

ios - AppStore 不允许使用 Wi-Fi 扫描仪

ios - 键盘将 UIView 推开

ios - DJI 无人机未连接(未调用 sdkManagerProductDidChange 委托(delegate)方法)

ios - 两个不同的 UIButton 中的日期选择器更新值

swift - UIBarButtonItem 的形状不正确

ios - NSDate 清零时分秒

objective-c - 在 iOS sdk 中解析本地 xml 文件

ios - 为什么我的按钮在 Swift Playgrounds 中不起作用?

ios - UIView ExclusiveTouch : strange behaviour with UIBarButtonItem

ios - 如何在 iOS 上的按钮中显示带下划线的文本?