2

我正在尝试在 ios 中进行拖动。如果拖动移动距离很短,我将通过比较 start x,y(来自 touchesBegan)与 touchesEnd 中的 x,y 来将拖动计为单击事件。似乎 touchesEnd 永远不会被调用。我放了一个断点来验证它,断点从未发生过。

code:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];

    [ self UpdateDrag];

   }

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];

    }


- (void) touchesEnd:(NSSet *)touches withEvent:(UIEvent *)event {
   // this methes never gets called 
    NSUInteger touchCount = [touches count];
    NSUInteger tapCount = [[touches anyObject] tapCount];


    if (mDisplay==nil)
    {
        mDisplay = [[cDisplayYesOrNo_iPhone alloc]
                    initWithNibName:@"cDisplayYesOrNo_iPhone"
                    bundle:[NSBundle mainBundle]];
    }
    [ mDisplay SetUp];
    [self presentModalViewController: mDisplay animated:NO];


}
4

2 回答 2

4

您需要编辑touchesEndtouchesEnded.

此外,为了完整起见,您需要考虑是否还需要响应touchesCancelledwhich is called 而不是touchesEnded在某些情况下。

于 2013-09-17T21:17:37.590 回答