iphone - motionEnded 未被调用(无 View Controller )

标签 iphone ipad ios shake motion

我认为我已尽我所能来检测震动,但 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/

相关文章:

ios - 如何强制 iOS 应用以纵向模式启动

ios - 我们如何为 iOS 手动测试生成 (profdata) 代码覆盖率?

iphone - 在 iPhone/iPad 项目中处理 WCF

iphone - 修复了背景图片在 iPad 和 iPhone 上无法正常工作的问题

ios - CIfilter中过滤值的最佳范围

ios - iPad UIWebView 与 iPhone 网站

ios - 带搜索栏的导航栏 iPad Monotouch

ios - 核心数据请求和保存的最佳实践

iPhone应用程序单元测试问题

iphone - 如何在 IOS 上管理 MKAnnotationView 的拖放?