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

    <tfoot id='IgHX1'></tfoot>

        Xcode iOS 按下按钮然后向上拖动第二个按钮

        时间:2023-07-06
          <tbody id='qihQc'></tbody>

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

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

                  问题描述

                  假设我不想给整数加 1.这只会在我按下 UIButton 然后松开手指在另一个 UIButton 上时完成.拖动组合.我可以使 IBAction 从组合中出现的最简单方法是什么?这可以通过触摸坐标来完成,或者只是 UIButtonsIBActions.

                  Lets say I wan't to add 1 to an integer. This will only be done when I push down on a UIButton and then release my finger on another UIButton. A drag combo. Whats the easiest way I can make an IBAction occur out of a combo? This could be done with touch coordinates or maybe just UIButtons and IBActions.

                  推荐答案

                  尝试将您希望触摸的按钮实现为Touch Down"、Touch Up Inside"和Touch Up Outside"按钮.

                  Try implementing the button you wish to touch down on as a "Touch Down", "Touch Up Inside", and "Touch Up Outside" button.

                  p>

                  UIButtons 可以响应许多不同类型的事件触摸取消触地触地重复触摸拖动输入触摸拖动退出触摸内部拖动触摸向外拖动修饰内部在外面修饰

                  UIButtons can respond to many differing types of events Touch Cancel Touch Down Touch Down Repeat Touch Drag Enter Touch Drag Exit Touch Drag Inside Touch Drag Outside Touch Up Inside Touch Up Outside

                  您可以为每个按钮的每个按钮实现不同的操作代码,以便最好地控制您想要的任何内容.简单的案例只使用了我上面提到的2个.

                  You can implement different action code for each of these for each button for best control of whatever you wish. The simplistic case only uses the 2 I mentioned above.

                  此代码已经过测试并且有效

                  THIS CODE HAS BEEN TESTED AND DOES WORK

                  在您的 ViewController 头文件中(这是我的):

                  In your ViewController header file (here was mine):

                  @interface ViewController : UIViewController{
                      IBOutlet UIButton * upButton;    // count up when finger released button
                      IBOutlet UIButton * downButton;
                      IBOutlet UILable * score;
                      BOOL isButtonDown;
                      unsigned int youCounter;
                  }
                  
                  -(IBAction)downButtonDown:(id)sender;
                  -(IBAction)downButtonUpInside:(id)sender;
                  -(IBAction)downButtonDragOutside:(id)sender event:(UIEvent *)event;
                  -(IBAction)downButtonUpOutside:(id)sender event:(UIEvent *)event;
                  
                  @end
                  

                  在您的 .xib 中,将向下按钮(您希望成为原始手指按下的按钮)连接到上面的正确操作.

                  In your .xib, connect the down button (the one you wish to be your original finger pressed button) to the proper actions above.

                  在您的 ViewController.m 文件中

                  In your ViewController.m file

                  -(void)viewDidLoad{
                      [super viewDidLoad];
                  
                      isButtonDown = NO;
                      youCounter   = 0;
                  }
                  
                  -(IBAction)downButtonDown:(id)sender{
                      isButtonDown = YES;
                  }
                  
                  -(IBAction)downButtonUpInside:(id)sender{
                      isButtonDown = NO;
                  }
                  
                  -(IBAction)downButtonDragOutside:(id)sender event:(UIEvent *)event{
                      NSArray theTouches = [[event allTouches] allObjects];
                  
                      [downButton setHighlighted:YES];
                  
                      if(YES == [upButton pointInside:[[theTouches objectAtIndex:0] locationInView:upButton] withEvent:event]){
                          [upButton setHighlighted:YES];
                      }else{
                          [upButton setHighlighted:NO];
                      }
                  }
                  
                  -(IBAction)downButtonUpOutside:(id)sender event:(UIEvent *)event{
                      if(YES == [upButton pointInside:[[theTouches objectAtIndex:0] locationInView:upButton] withEvent:event]){
                          youCounter++;
                          score.text = [NSString stringWithFormat:@"Score = %d", youCounter];
                      }
                  
                      [downButton setHighlighted:NO];
                      [upButton setHighlighted:NO];
                  }
                  

                  这篇关于Xcode iOS 按下按钮然后向上拖动第二个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:以编程方式添加按钮以执行 segue 下一篇:自定义 UIAlertView 上的按钮

                  相关文章

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

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

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

                    2. <tfoot id='nXZro'></tfoot>

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