仅在按下按钮后如何动作摇动? [英] How to motion shake only after a button?

查看:63
本文介绍了仅在按下按钮后如何动作摇动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何在之前停止响应摇动按下按钮?

我有一个应用,当前,如果您单击播放"按钮,标签显示中说摇一摇",问题是我是一个初学者,我不知道如何订购它,因此用户必须先按下按钮,然后在显示标签时,如果用户摇动,则标签消失.这就是我所需要的,因为在此之后我已经对应用程序的其他部分进行了整理.感谢所有提供帮助的人,请记住我还很陌生,所以请解释所有答案:)谢谢

I have a app and currently if you click the button 'Play' a label show's saying 'Shake to Play' the problem is I am a total beginner and I don't know how to order it so the user has to first press the button, then when the label show's, if the user shake's the label disappears. that's all I need because I have sorted out other parts of the app after that. Thanks to anyone who helps, remember I am quite new so please explain any answers :) thanks

推荐答案

创建BOOL类型的实例变量.称它为playIsTouched.在视图控制器的viewDidLoad方法中将其设置为NO.在处理播放"按钮的触摸的方法中,将playIsTouched设置为YES.在处理抖动的方法中,仅当playIsTouched == YES时,使标签消失.在相同的方法中,您可能需要将playIsTouched设置回NO(如果您希望用户在摇动前再次触摸按钮).

Create an instance variable of type BOOL. Call it, say, playIsTouched. Set it to NO in the view controller's viewDidLoad method. In the method that handles touches to the Play button, set playIsTouched to YES. In the method that handles shakes, make the label disappear only if playIsTouched == YES. In the same method, you may want to set playIsTouched back to NO (if you want to user to touch the button again before shaking).

这篇关于仅在按下按钮后如何动作摇动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆