【发布时间】:2011-07-17 23:41:28
【问题描述】:
我正在尝试检测设备(iPhone/iPod Touch)何时抖动,我已经完成的(在我的 viewController.m 中)是:
- (BOOL) canBecomeFirstResponder{
return YES;
}
.
- (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if (motion == UIEventSubtypeMotionShake){
NSLog(@"Motion detected");
}
}
我已将此行添加到 viewDidLoad :
BOOL ret = [self becomeFirstResponder];
然后,我构建并运行应用程序,并尝试摇动设备但没有任何反应!.. 我开始解决问题,通过使用断点,我检测到从 [self becomeFirstResponder] 返回的“ret”值是“不”。 并且不知道是什么问题。有什么帮助吗?
Info : using Xcode 4, and iOS 4.3
提前致谢。
【问题讨论】:
标签: cocoa-touch ios accelerometer shake first-responder