如何将iPhone抖动手势检测限制在特定情况下?
我成功地实现了摇晃手势,但现在我想限制它仅在一种特定情况下激活(在我的应用程序的选项面板中)如何将iPhone抖动手势检测限制在特定情况下?,iphone,objective-c,ios,accelerometer,shake,Iphone,Objective C,Ios,Accelerometer,Shake,我成功地实现了摇晃手势,但现在我想限制它仅在一种特定情况下激活(在我的应用程序的选项面板中) 我首先创建了ShakeWindow类,它是UIWindow的一个子类。在ShakeWindow中,我添加了-(void)motionEnded:(UIEventSubtype)motion with event:(UIEvent*)event,以注册抖动手势 接下来,我转到AppDelegate.m并编辑了window=[[UIWindow alloc]initWithFrame:[UIScreen
- 我首先创建了ShakeWindow类,它是UIWindow的一个子类。在ShakeWindow中,我添加了
,以注册抖动手势-(void)motionEnded:(UIEventSubtype)motion with event:(UIEvent*)event
- 接下来,我转到AppDelegate.m并编辑了
使用新的ShakeWindow而不是UIWindowwindow=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen]bounds]
我使用Cocos2D作为框架,如果有关系的话,我不使用界面生成器。我可能会误解,但是
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (/* conditions where my app responds to shake */) {
// respond to shake
}
// otherwise, it's like it never happened
}
我可能误解了,但是
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (/* conditions where my app responds to shake */) {
// respond to shake
}
// otherwise, it's like it never happened
}
我必须说,有时候我会让最简单的事情看起来比实际情况更难。谢谢。我必须说,有时候我会让最简单的事情看起来比实际情况更难。非常感谢。