<i id='zkpvL'><tr id='zkpvL'><dt id='zkpvL'><q id='zkpvL'><span id='zkpvL'><b id='zkpvL'><form id='zkpvL'><ins id='zkpvL'></ins><ul id='zkpvL'></ul><sub id='zkpvL'></sub></form><legend id='zkpvL'></legend><bdo id='zkpvL'><pre id='zkpvL'><center id='zkpvL'></center></pre></bdo></b><th id='zkpvL'></th></span></q></dt></tr></i><div id='zkpvL'><tfoot id='zkpvL'></tfoot><dl id='zkpvL'><fieldset id='zkpvL'></fieldset></dl></div>

        <small id='zkpvL'></small><noframes id='zkpvL'>

          <bdo id='zkpvL'></bdo><ul id='zkpvL'></ul>
        <legend id='zkpvL'><style id='zkpvL'><dir id='zkpvL'><q id='zkpvL'></q></dir></style></legend>
        <tfoot id='zkpvL'></tfoot>

        更改 UIButton 文本

        时间:2023-08-31

      1. <legend id='RKyR6'><style id='RKyR6'><dir id='RKyR6'><q id='RKyR6'></q></dir></style></legend>
        <i id='RKyR6'><tr id='RKyR6'><dt id='RKyR6'><q id='RKyR6'><span id='RKyR6'><b id='RKyR6'><form id='RKyR6'><ins id='RKyR6'></ins><ul id='RKyR6'></ul><sub id='RKyR6'></sub></form><legend id='RKyR6'></legend><bdo id='RKyR6'><pre id='RKyR6'><center id='RKyR6'></center></pre></bdo></b><th id='RKyR6'></th></span></q></dt></tr></i><div id='RKyR6'><tfoot id='RKyR6'></tfoot><dl id='RKyR6'><fieldset id='RKyR6'></fieldset></dl></div>
          <tbody id='RKyR6'></tbody>
          <tfoot id='RKyR6'></tfoot>

              <bdo id='RKyR6'></bdo><ul id='RKyR6'></ul>

                  <small id='RKyR6'></small><noframes id='RKyR6'>

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

                  问题描述

                  所以我试图在单击 UIButton 时更新它的文本.我正在使用以下行来更改文本:

                  So I'm trying to update the text on a UIButton when I click it. I'm using the following line to change the text:

                  calibrationButton.titleLabel.text = @"Calibration";
                  

                  我已验证文本正在更改,但是当我运行应用程序并单击按钮时,它会在一瞬间更改为校准",然后立即恢复为默认值.任何想法为什么会发生这种情况?我需要调用某种刷新函数吗?

                  I have verified that the text is changing, but when I run the app and I click on the button, it changes to "Calibration" for a split second and then goes right back to its default value. Any ideas why this might be happening? Is there some sort of refresh function I need to be calling?

                  推荐答案

                  在布局子视图时,UIButton 会使用自己的标题值设置其 titleLabel 的文本值,这样您就可以为这四个设置最多四个不同的字符串状态(正常、突出显示、选中、禁用).

                  When laying out its subviews, a UIButton will set its titleLabel's text value using its own title values, so that you can set up to four different strings for the four states (normal, highlighted, selected, disabled).

                  因为这个特性,直接设置titleLabel的文本不会持久化,会在布局子视图时被按钮重置.

                  Because of this feature, setting the titleLabel's text directly won't persist, and will be reset by the button when it lays out its subviews.

                  这是更改按钮状态的标题文本所必须执行的操作.

                  This is what you have to do to change the title text for a button's state.

                  [calibrationButton setTitle:@"Calibration" forState:UIControlStateNormal];
                  

                  这篇关于更改 UIButton 文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何正确使用 swipeWithEvent 导航 webView,Obj-C 下一篇:在 Android 上监听音量变化事件

                  相关文章

                  最新文章

                  <legend id='1itj0'><style id='1itj0'><dir id='1itj0'><q id='1itj0'></q></dir></style></legend>

                • <tfoot id='1itj0'></tfoot>

                  <i id='1itj0'><tr id='1itj0'><dt id='1itj0'><q id='1itj0'><span id='1itj0'><b id='1itj0'><form id='1itj0'><ins id='1itj0'></ins><ul id='1itj0'></ul><sub id='1itj0'></sub></form><legend id='1itj0'></legend><bdo id='1itj0'><pre id='1itj0'><center id='1itj0'></center></pre></bdo></b><th id='1itj0'></th></span></q></dt></tr></i><div id='1itj0'><tfoot id='1itj0'></tfoot><dl id='1itj0'><fieldset id='1itj0'></fieldset></dl></div>
                    • <bdo id='1itj0'></bdo><ul id='1itj0'></ul>

                    1. <small id='1itj0'></small><noframes id='1itj0'>