所以让我首先澄清一下我已经实现了哪些代码
-(BOOL)canBecomeFirstResponder
{
return YES;
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self becomeFirstResponder];
}
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
NSLog(@"FUUU");
}
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
NSLog(@"FUUU");
}
}
这都在 UIViewController 类中
- (void) applicationDidFinishLaunching:(UIApplication*)application
我已经设置了
[application setApplicationSupportsShakeToEdit:YES];
然而它什么也没做,没有检测到任何单一的运动。我不确定还能做什么。这似乎对许多其他人有效,所以我很困惑为什么我与众不同......可能是因为它是通过 UINavigationController 吗?或者因为我通过 plist 加载主应用程序而我的主应用程序看起来像这样
retVal = UIApplicationMain(argc, argv, nil, nil);
我完全被难住了。