我想在整个应用程序中集成抖动功能。所以我在 appDelegate 中做所有事情。我需要推送一个viewController,我可以推送motionBegan,但我想做motionEnded。是的,运动结束确实在视图控制器中工作,但在应用程序委托中它没有被调用。作为
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self becomeFirstResponder];
}
- (BOOL)canBecomeFirstResponder{
return YES;
}
未调用motionEnded
-(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if(event.subtype==UIEventSubtypeMotionShake){
NSLog(@"motionEnded called");
}
}
运动开始调用
-(void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if(event.subtype==UIEventSubtypeMotionShake){
NSLog(@"motionBegan called");
}
}