0

我实现了摇动手势事件。当摇晃发生时,我会做一些事情。

但是,如果显示警报,我不会收到事件。

这是我所拥有的:

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:YES];
    // Register for shake detection
    [self becomeFirstResponder];
}

- (BOOL) canBecomeFirstResponder{
    return YES;
}


- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {

    if (motion == UIEventSubtypeMotionShake){
         DLog(@"Shake ended");
    }
}

显示警报时是否可以摇动手势?

4

1 回答 1

0

尝试这个

 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if ( event.subtype == UIEventSubtypeMotionShake )
    {
        // Put in code here to handle shake
    }

    if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
        [super motionEnded:motion withEvent:event];
}

- (BOOL)canBecomeFirstResponder
{ return YES; }
于 2013-07-25T13:08:04.490 回答