- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在我的应用程序中集成了摇晃识别功能。我已将它放在我的 appdelegate 中,以便能够在整个应用程序中使用它。它在 iOS 5 上运行良好,但在 iOS 4 上不起作用。
我在我的 appdelegate.m 中使用了以下代码:
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self becomeFirstResponder];
....
}
-(BOOL)canBecomeFirstResponder {
return YES;
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"motionBegan");
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
NSLog(@"motionEnded");
}
如果我在 iOS5 模拟器中运行它并激活摇动手势,我会收到 NSLog 消息。如果我在 iOS 4.3 模拟器中运行它,它不起作用。与真实设备相同。
最佳答案
我遇到了同样的问题。尝试
- (void)viewDidAppear:(BOOL)animated {
[self becomeFirstResponder];
}
代替
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self becomeFirstResponder];
....
}
如 Event Handling Guide: Motion Events .这对我有用。
关于ios - 摇晃识别在 iOS 4 上不起作用,但在 iOS 5 上有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8458616/
我想让我的 UICollectionViewCell 在长时间按下 (UILongPressGestureRecognizer) 后摇晃以便删除一个项目。 我读过这个post和另一个 one . 我按
我有两个 SkSpriteNode,分别是 left-ball 和 right-ball。它们从屏幕的两侧流出。 我为这两个球实现了碰撞检测。但是我注意到,在我添加碰撞检测之前,球在没有任何晃动效果的
我在使用Github的 Action 时遇到了一个奇怪的问题。我有一个Gradle任务,可以将发行说明打印到文件中(在本地工作得很好)。但是使用GitHub操作似乎无法将–pretty=format:
我将 Cannon.js 与 Three.js 结合使用。我设置了一个场景,其中有 5 列,每列 4 个 block 相互堆叠。 我希望它们能够与我计划添加到场景中的其他对象进行交互。然而,列中的 b
我在 tableview 上使用了自动布局,但在 HeightforRowAtIndexPath 中计算了图像框架、标题和副标题以及高度。 & 滚动 tableview 抖动 最佳答案 在 viewD
我是一名优秀的程序员,十分优秀!