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

  3. <small id='Md0id'></small><noframes id='Md0id'>

        <bdo id='Md0id'></bdo><ul id='Md0id'></ul>
    1. touchesBegin &amp;touchesMove Xcode Obj C 问题

      touchesBegin amp; touchesMove Xcode Obj C Question(touchesBegin amp;touchesMove Xcode Obj C 问题)

        <tbody id='uX0aR'></tbody>
            <bdo id='uX0aR'></bdo><ul id='uX0aR'></ul>
            <tfoot id='uX0aR'></tfoot>

              • <small id='uX0aR'></small><noframes id='uX0aR'>

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

                问题描述

                所以当您按下并拖动时,我的应用程序运行良好.我还在 Interface Builder 中将 UIButtons 设置为 Touch Down.

                So I have my app working good when you press and drag along. I also have UIButtons set to Touch Down in Interface Builder.

                当您拖动时,您需要从 UIButton 的外部拖动.您不能单击 UIButton 并拖动到另一个.

                As well when you drag you need to drag from the outside of the UIButton. You cannot click on the UIButton and drag to the other.

                触摸移动:

                代码:

                -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
                
                UITouch *touch = [[event touchesForView:self.view] anyObject];
                CGPoint location = [touch locationInView:touch.view];
                
                if(CGRectContainsPoint(oneButton.frame, location))
                {
                    if (!oneButton.isHighlighted){
                        [self oneFunction];
                        [oneButton setHighlighted:YES];
                    }
                }else {
                    [oneButton setHighlighted:NO];
                }
                //
                if(CGRectContainsPoint(twoButton.frame, location)) 
                {
                    if (!twoButton.isHighlighted){
                        [self twoFunction];
                        [twoButton setHighlighted:YES];
                    }
                }else {
                    [twoButton setHighlighted:NO];
                }
                

                }

                开始接触:

                代码:

                - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
                
                   UITouch *touch = [[event touchesForView:self.view] anyObject];
                
                CGPoint location = [touch locationInView:touch.view];
                
                if(CGRectContainsPoint(oneButton.frame, location))
                {
                    [self oneFunction];
                    [oneButton setHighlighted:YES];
                }
                if(CGRectContainsPoint(twoButton.frame, location))
                {
                    [self twoFunction];
                    [twoButton setHighlighted:YES];
                }
                

                }

                我希望能够点击任何按钮来触发功能&也可以从一个按钮拖动到另一个按钮并触发该功能.

                I want to be able to click on any of the button fire the function & also be able to drag from one button on to the other and fire that function.

                所以基本上只需点击一个按钮并将手指滑过并激活另一个按钮,而无需从按钮外部按下和滑动.

                So basically just being able to click on a button and slide your finger over and activate the other button without having to press and slide from outside of the button.

                我想我已经很接近了,需要一些帮助.希望这足够清楚.

                I think I'm close, need a bit of help. Hope thats clear enough.

                谢谢.

                推荐答案

                尝试了一些不同的东西.使用它效果更好:

                Tried something different. Using this worked much better:

                if(CGRectContainsPoint(myObject.frame, location) && lastButton != myObject) {
                

                在 touchesBegan &touchesMoved.

                Used it in touchesBegan & touchesMoved.

                这篇关于touchesBegin &amp;touchesMove Xcode Obj C 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 删除所有目标动作)
                  <tbody id='gbpu6'></tbody>
                <tfoot id='gbpu6'></tfoot>
                <i id='gbpu6'><tr id='gbpu6'><dt id='gbpu6'><q id='gbpu6'><span id='gbpu6'><b id='gbpu6'><form id='gbpu6'><ins id='gbpu6'></ins><ul id='gbpu6'></ul><sub id='gbpu6'></sub></form><legend id='gbpu6'></legend><bdo id='gbpu6'><pre id='gbpu6'><center id='gbpu6'></center></pre></bdo></b><th id='gbpu6'></th></span></q></dt></tr></i><div id='gbpu6'><tfoot id='gbpu6'></tfoot><dl id='gbpu6'><fieldset id='gbpu6'></fieldset></dl></div>

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

                  <legend id='gbpu6'><style id='gbpu6'><dir id='gbpu6'><q id='gbpu6'></q></dir></style></legend>
                    <bdo id='gbpu6'></bdo><ul id='gbpu6'></ul>