我实施了摇动手势事件。当发生震动时,我会做一些事情。
但是,如果显示警报,我就不会收到事件。
这就是我所拥有的:
- (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");
}
}
显示警报时是否可以获得摇动手势?
答案 0 :(得分: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; }