【发布时间】:2012-11-09 21:13:50
【问题描述】:
我对应用程序开发有点陌生。在 viewController ( VPviewController ) 我有以下代码:
- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if (motion == UIEventSubtypeMotionShake){
[self startGame:nil];
}
}
在不同的 viewController (VPgameViewController) 中,我有不同的 MotionShake 事件:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if(event.subtype == UIEventSubtypeMotionShake){
if(count < 3 ){
[self changeText:nil];
AudioServicesPlaySystemSound(1016);
count++;
}else{
count = 0;
AudioServicesPlaySystemSound(1024);
UIStoryboard *storyboard = self.storyboard;
VPpoepViewController *shit = [storyboard instantiateViewControllerWithIdentifier:@"PoepViewController"];
shit.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:shit animated:YES completion:nil];
}
}
}
当我在 VPgameView 中摇动 Iphone 时,它也会调用另一个 viewController 摇动事件中的 startGame 函数。
我怎样才能阻止这种情况?
【问题讨论】:
-
在这两种观点中,我都可以成为第一响应者并辞去第一响应者的职务。但这无济于事。
-
您想在 Xcode 中还是在 iOS 中检测运动?如果是后者,请不要将 iOS 与 Xcode 混淆。编写 iOS 应用程序不需要 Xcode。
标签: iphone xcode ios4 ios6 motion-detection