【问题标题】:Has anyone managed to get the iPad iOS 10 simulator to trigger a shake event?有没有人设法让 iPad iOS 10 模拟器触发震动事件?
【发布时间】:2016-09-27 09:46:13
【问题描述】:
在 iOS 10 模拟器中突然崩溃。
准备:
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
实施:
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
而且 -motionBegan 永远不会被调用。
【问题讨论】:
标签:
ios-simulator
ios10
motion
【解决方案1】:
好的,事实证明他们已经改变了它的工作方式,而我上面的“准备”现在在 iOS 10 中是不够的。你不需要设置它。
现在您必须在将接收事件的第一响应者中实现motionBegan,如果是您的VC,您需要实现:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[self becomeFirstResponder];
}