更改 UIButton 的标题不起作用 [英] changing title of UIButton not working

查看:45
本文介绍了更改 UIButton 的标题不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 tableview 单元格中添加了一个按钮.我的问题是,当我在调用方法 pressHonkBtn:(id)sender 时更改其标题时,它没有更改其标题.

I have added a button in tableview cell. My problem is this when I change its title on calling method pressHonkBtn:(id)sender it's not changing its title.

如何解决这个问题.

推荐答案

使用你的代码:

目标 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];
}

斯威夫特:

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

希望对你有帮助.

这篇关于更改 UIButton 的标题不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆