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

    1. <tfoot id='5ICE9'></tfoot>

        <small id='5ICE9'></small><noframes id='5ICE9'>

        从 UILabel Swift 中获取 Int

        Get an Int out of an UILabel Swift(从 UILabel Swift 中获取 Int)

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

            <tbody id='F6Fo8'></tbody>
          <tfoot id='F6Fo8'></tfoot>

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

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

                  本文介绍了从 UILabel Swift 中获取 Int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个问题,有大量按钮以数字作为标签,所以我认为我可以将标签作为整数而不是为每个按钮创建一个动作?!

                  I have the problem, to have a high amount of buttons which have a number as their label, so i thought i could take the label as an integer instead of creating an action for every button?!

                  @IBAction func NumberInput(sender: UIButton) {
                      var input:Int = sender.titleLabel as Int
                  }
                  

                  推荐答案

                  如果你想这样做,你可以使用 string 转换为 Int>string.toInt() 如:

                  If you want to do this, you can convert the string to an Int by using string.toInt() such as:

                  if let input = sender.titleLabel?.text?.toInt() {
                      // do something with input
                  } else {
                      // The label couldn't be parsed into an int
                  }
                  

                  但是,我建议使用 UIView.tag 或子类化 UIButton 并向其添加 Int 属性来完成此操作,在以防您更改标签的显示.

                  However, I'd suggest either using UIView.tag or subclassing UIButton and adding an Int property to it to accomplish this, in case you ever change the display of your labels.

                  这篇关于从 UILabel Swift 中获取 Int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UIButton title text color(UIButton 标题文本颜色)
                  Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                  Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                  How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                  iPhone UIButton - image position(iPhone UIButton - 图像位置)
                  UIButton remove all target-actions(UIButton 删除所有目标动作)
                  <i id='Bh763'><tr id='Bh763'><dt id='Bh763'><q id='Bh763'><span id='Bh763'><b id='Bh763'><form id='Bh763'><ins id='Bh763'></ins><ul id='Bh763'></ul><sub id='Bh763'></sub></form><legend id='Bh763'></legend><bdo id='Bh763'><pre id='Bh763'><center id='Bh763'></center></pre></bdo></b><th id='Bh763'></th></span></q></dt></tr></i><div id='Bh763'><tfoot id='Bh763'></tfoot><dl id='Bh763'><fieldset id='Bh763'></fieldset></dl></div>
                    <legend id='Bh763'><style id='Bh763'><dir id='Bh763'><q id='Bh763'></q></dir></style></legend>
                        <tbody id='Bh763'></tbody>

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

                          • <bdo id='Bh763'></bdo><ul id='Bh763'></ul>
                          • <tfoot id='Bh763'></tfoot>