iphone – xcode ios 6摇动动作从前一个视图调用IBaction

iphone – xcode ios 6摇动动作从前一个视图调用IBaction,第1张

概述我对应用程序开发有点新意.在viewController(VPviewController)中,我有以下代码: - (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if (motion == UIEventSubtypeMotionShake){ [self start 我对应用程序开发有点新意.在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时,它还调用了startGame函数,该函数位于不同的vIEwController震动事件中.

我怎么能阻止这个?

解决方法 听起来你必须取消订阅你的VPVIEwController才能在其vIEwWilldisappear:function中接收摇动事件通知.

通常,如果您希望vIEwController仅在可见时接收某些事件通知,则应在vIEwWillAppear:function中订阅通知,并在vIEwWilldisappear:function中订阅取消订阅.

总结

以上是内存溢出为你收集整理的iphone – xcode ios 6摇动动作从前一个视图调用IBaction全部内容,希望文章能够帮你解决iphone – xcode ios 6摇动动作从前一个视图调用IBaction所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1055008.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存