作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我成功地实现了摇动手势,但现在我想限制它只在一种特定情况下激活(在我的应用程序的选项面板中)。
我首先创建了 ShakeWindow 类,它是 UIWindow 的子类。在 ShakeWindow 中,我添加了 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
来注册摇动手势。
接下来我转到 AppDelegate.m 并编辑 window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
以使用新的 ShakeWindow 而不是 UIWindow。
它很好用,但我如何限制它的功能?我刚刚开始使用 Objective-C,并且认为自己总体上是一个新手编码员,所以在回答时请记住这一点,谢谢!
我使用 Cocos2D 作为框架,如果这些很重要,我不使用 Interface Builder。
最佳答案
我可能误会了,但是...
- (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
}
关于iphone - 如何将 iPhone 摇动手势检测限制在特定情况下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9863170/
我是一名优秀的程序员,十分优秀!