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

  • <legend id='XRhhj'><style id='XRhhj'><dir id='XRhhj'><q id='XRhhj'></q></dir></style></legend>

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

      • <bdo id='XRhhj'></bdo><ul id='XRhhj'></ul>
        <tfoot id='XRhhj'></tfoot>
      1. UIButton长按手指不动

        UIButton long press with finger stationary(UIButton长按手指不动)
          • <legend id='GNeH8'><style id='GNeH8'><dir id='GNeH8'><q id='GNeH8'></q></dir></style></legend>

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

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

                1. <tfoot id='GNeH8'></tfoot>

                    <tbody id='GNeH8'></tbody>
                  本文介绍了UIButton长按手指不动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的项目中,我需要使用 UIButton(或其他组件)通过长按来处理事件.让我解释一下,我应该记住我按住按钮一个计时器来计算秒数并释放压力停止,我尝试使用 UILongPressGestureRecognizer 的管理但不是这种情况,因为我记得按下按钮时的事件但是仅当我移动手指时,但我希望计时器消失并计数所有按住按钮的时间(手指静止)并在松开手指时停止计数.

                  In my project I have the need to use a UIButton (or another component) to handle events using long press. Let me explain, I should make that mind I hold down the button a timer to count the seconds and release to pressure stop, I tried with the management of UILongPressGestureRecognizer but is not the case because I recall the event when the button is held down but only if I move my finger, but I wish the timer went away and counted all the time in which the button is held down (with your finger stationary) and stopped counting when the finger is released.

                  有人知道如何帮助我吗?谢谢

                  Does anyone know how to help me? Thanks

                  推荐答案

                  对按钮事件使用这两种方法.touchDown 在你按下按钮时被调用,touchUp 在你手指离开按钮时被调用.计算这两种方法之间的时间差.您也可以在 touchDown 中启动计时器并在 touchUp 中停止/重新启动它.

                  Use these two methods for buttons events. touchDown is called when you press the button and touchUp will be called when you lift your finger from the button. Calculate the time difference between these two methods. Also you can start timer in touchDown and stop/restart it in touchUp.

                  //connect this action with Touch up inside
                  - (IBAction)touchUp:(id)sender {
                      NSLog(@"up");
                  }
                  
                  //connect this to tocuh down
                  - (IBAction)touchDown:(id)sender{
                      NSLog(@"down");
                  }
                  

                  <小时>

                  更新在编码中你可以这样写

                  [btn addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside];
                  [btn addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchDown];
                  

                  在 xib

                  这篇关于UIButton长按手指不动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 标题颜色?)
                  Minimum sensible button size on iPhone(iPhone 上的最小合理按钮大小)
                  iPhone UIButton - image position(iPhone UIButton - 图像位置)

                    <bdo id='5ukWu'></bdo><ul id='5ukWu'></ul>

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

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

                          <tbody id='5ukWu'></tbody>
                          1. <legend id='5ukWu'><style id='5ukWu'><dir id='5ukWu'><q id='5ukWu'></q></dir></style></legend>