我认为我已尽我所能来检测震动,但 motionEnded:withEvent:
从未被调用。 (一个问题是我没有 UIViewController
- 我的应用程序基于“OpenGL ES App”模板。)
我已将 application.applicationSupportsShakeToEdit = YES;
添加到我的 application:didFinishLaunchingWithOptions:
和
- (BOOL)canBecomeFirstResponder { return YES; }
到 EAGLView.m(确实会被调用),以及 [self becomeFirstResponder];
到 initWithCoder:
(也尝试过其他各种地方)。
但是调试器永远不会命中
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
我错过了一些步骤吗?我必须要有 Controller 吗?
(我在 iPad 模拟器中使用 iOS 3.2。)
最佳答案
您必须将此添加到您的 Controller :
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
-(BOOL)becomeFirstResponder
{
return YES;
}
关于iphone - motionEnded 未被调用(无 View Controller ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3534858/