<legend id='6jUHt'><style id='6jUHt'><dir id='6jUHt'><q id='6jUHt'></q></dir></style></legend>

  • <small id='6jUHt'></small><noframes id='6jUHt'>

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

      1. 如何以编程方式将触摸事件伪造为 UIButton?

        时间:2023-07-09
      2. <i id='jhCYG'><tr id='jhCYG'><dt id='jhCYG'><q id='jhCYG'><span id='jhCYG'><b id='jhCYG'><form id='jhCYG'><ins id='jhCYG'></ins><ul id='jhCYG'></ul><sub id='jhCYG'></sub></form><legend id='jhCYG'></legend><bdo id='jhCYG'><pre id='jhCYG'><center id='jhCYG'></center></pre></bdo></b><th id='jhCYG'></th></span></q></dt></tr></i><div id='jhCYG'><tfoot id='jhCYG'></tfoot><dl id='jhCYG'><fieldset id='jhCYG'></fieldset></dl></div>

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

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

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

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

                  本文介绍了如何以编程方式将触摸事件伪造为 UIButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一些单元测试,并且由于这个特定应用程序的性质,重要的是我要在 UI 链中尽可能高.所以,我想做的是以编程方式触发按钮按下,就好像用户按下了 GUI 中的按钮一样.

                  I'm writing some unit tests and, because of the nature of this particular app, it's important that I get as high up the UI chain as possible. So, what I'd like to do is programmatically trigger a button-press, as if the user had pressed the button in the GUI.

                  (是的,是的——我可以只调用 IBAction 选择器,但同样,这个特定应用程序的性质使得我假装实际按下按钮很重要,以便从按钮本身调用 IBAction.)

                  (Yes, yes -- I could just call the IBAction selector but, again, the nature of this particular app makes it important that I fake the actual button press, such that the IBAction be called from the button, itself.)

                  这样做的首选方法是什么?

                  What's the preferred method of doing this?

                  推荐答案

                  原来如此

                  [buttonObj sendActionsForControlEvents:UIControlEventTouchUpInside];
                  

                  在这种情况下,我得到了我需要的东西.

                  got me exactly what I needed, in this case.

                  不要忘记在主线程中执行此操作,以获得类似于用户按下的结果.

                  Don't forget to do this in the main thread, to get results similar to a user-press.

                  对于 Swift 3:

                  buttonObj.sendActions(for: .touchUpInside)
                  

                  这篇关于如何以编程方式将触摸事件伪造为 UIButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:颜色色调 UIButton 图像 下一篇:通过发件人在 Swift 上获取按钮按下的 id

                  相关文章

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

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

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