我对应用程序开发有点陌生。在 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 函数。
我怎么能阻止这个?