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

      • <bdo id='kOzoC'></bdo><ul id='kOzoC'></ul>
      1. <legend id='kOzoC'><style id='kOzoC'><dir id='kOzoC'><q id='kOzoC'></q></dir></style></legend>

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

        如何使用 UIButton 作为切换按钮?

        时间:2023-07-08

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

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

            1. <legend id='S6KtU'><style id='S6KtU'><dir id='S6KtU'><q id='S6KtU'></q></dir></style></legend>
              1. <tfoot id='S6KtU'></tfoot>
                  <tbody id='S6KtU'></tbody>

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

                  本文介绍了如何使用 UIButton 作为切换按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试为表格中的每个单元格创建一个切换按钮.按下时,它将更改图像,再次按下时将再次更改图像 - 切换.

                  I am trying to create a toggle button for each cell in my table. When pressed, it will change the image and when pressed again it will change the image again -- Toggle.

                  UIButton 类中,我看不到 selected 状态.

                  In the UIButton class I don't see a selected state.

                  我正在寻找一种使用 UIButton 创建切换按钮的方法,以便我可以更改每次单击时的状态.

                  I'm looking for a way to create a toggle button with UIButton so that I can change the state on each click.

                  这就是我现在在 rubymotion 中使用 rmq

                  This is how I'm doing it in rubymotion right now using rmq

                  @fav_button.on(:touch) do |sender|
                    puts "pressed fav button for id: " + data[:id] + " and name: " + data[:name]
                    #how do I change the state here?
                  end
                  

                  推荐答案

                  您可以轻松创建切换按钮,您只需为各个状态设置相应的图像,然后就可以使用 selected属性在这些图像之间切换.

                  You can create toggle button easily, you just need to set respective images for respective states, after that, you can use the selected property to toggle between these images.

                  我制作了一个纯 Objective-c 代码来展示你如何做到这一点,但你也可以在 Storyboards 或 Xibs 中设置图像,查看:

                  I made a pure objective-c code to show how you can do that, but you can set the images anyway in Storyboards ou Xibs too, check out:

                  // First, set the images for normal state and selected state
                  [button setImage:normalImage forState:UIControlStateNormal];
                  [button setImage:selectedImage forState:UIControlStateSelected];
                  


                  // Don't forget to add an action handler to toggle the selected property
                  [button addTarget:self action:@selector(buttonTouch:withEvent:) forControlEvents:UIControlEventTouchUpInside];
                  


                  // Now, in your button action handler, you can do something like this:
                  - (void)buttonTouch:(UIButton *)aButton withEvent:(UIEvent *)event
                  {
                    aButton.selected = !aButton.selected;
                  }
                  

                  希望对你有帮助.

                  这篇关于如何使用 UIButton 作为切换按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在两个 UIButton 图像之间淡入淡出 下一篇:在另一个 xib 中使用 xib 对象

                  相关文章

                  <tfoot id='cKUw4'></tfoot>

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

                      <legend id='cKUw4'><style id='cKUw4'><dir id='cKUw4'><q id='cKUw4'></q></dir></style></legend>

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