<tfoot id='I6yzi'></tfoot>

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

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

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

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

    3. UIButton 长按事件

      UIButton Long Press Event(UIButton 长按事件)
        <tbody id='i6vY2'></tbody>

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

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

              • <legend id='i6vY2'><style id='i6vY2'><dir id='i6vY2'><q id='i6vY2'></q></dir></style></legend>
                <i id='i6vY2'><tr id='i6vY2'><dt id='i6vY2'><q id='i6vY2'><span id='i6vY2'><b id='i6vY2'><form id='i6vY2'><ins id='i6vY2'></ins><ul id='i6vY2'></ul><sub id='i6vY2'></sub></form><legend id='i6vY2'></legend><bdo id='i6vY2'><pre id='i6vY2'><center id='i6vY2'></center></pre></bdo></b><th id='i6vY2'></th></span></q></dt></tr></i><div id='i6vY2'><tfoot id='i6vY2'></tfoot><dl id='i6vY2'><fieldset id='i6vY2'></fieldset></dl></div>
                <tfoot id='i6vY2'></tfoot>
              • 本文介绍了UIButton 长按事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想模拟一个长按按钮,我该怎么做?我认为需要一个计时器.我看到 UILongPressGestureRecognizer 但我该如何使用这种类型?

                I want to emulate a long a press button, how can I do this? I think a timer is needed. I see UILongPressGestureRecognizer but how can I utilize this type?

                推荐答案

                您可以从创建 UILongPressGestureRecognizer 实例并将其附加到按钮开始.

                You can start off by creating and attaching the UILongPressGestureRecognizer instance to the button.

                UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
                [self.button addGestureRecognizer:longPress];
                [longPress release];
                

                然后实现处理手势的方法

                And then implement the method that handles the gesture

                - (void)longPress:(UILongPressGestureRecognizer*)gesture {
                    if ( gesture.state == UIGestureRecognizerStateEnded ) {
                         NSLog(@"Long Press");
                    }
                }
                

                现在这将是基本方法.您还可以设置压力机的最短持续时间以及可以容忍的错误量.另请注意,如果您在识别手势后调用该方法几次,因此如果您想在结束时执行某些操作,则必须检查其状态并进行处理.

                Now this would be the basic approach. You can also set the minimum duration of the press and how much error is tolerable. And also note that the method is called few times if you after recognizing the gesture so if you want to do something at the end of it, you will have to check its state and handle it.

                这篇关于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 标题颜色?)
                iPhone UIButton - image position(iPhone UIButton - 图像位置)
                UIButton remove all target-actions(UIButton 删除所有目标动作)

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

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

                    <bdo id='B2VYQ'></bdo><ul id='B2VYQ'></ul>
                        <tbody id='B2VYQ'></tbody>
                        • <legend id='B2VYQ'><style id='B2VYQ'><dir id='B2VYQ'><q id='B2VYQ'></q></dir></style></legend>