显示图像几秒钟

发布于 2024-09-01 00:54:49 字数 91 浏览 5 评论 0原文

我希望能够在设备晃动时在 iPhone 上显示图像。我可以播放声音,但同时也想弹出图像。
任何关于如何做到这一点的想法将不胜感激。

谢谢, 韦斯

I want to be able to display an image on the iPhone when the device is shaken. I can play a sound but also want to pop up an image at the same time.
Any ideas on how to do this would be appreciated.

thx,
wes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆头 2024-09-08 00:54:49

我会怎样做呢?

  1. 在头文件中,定义一个 UIImageView。
  2. 当您的设备摇晃时,使用右框架初始化视图
  3. 在该 UIImageView 中加载图像。
  4. 将该 UIImageView 添加到当前显示的视图中。
  5. 创建一个 NSTimer,它的时间间隔是您想要显示图像的时间间隔。
  6. 当计时器达到其时间间隔时,从视图中删除 imageview。

我不会在这里放置各种代码,因为您也没有提供任何代码,但我认为您可以自己弄清楚。

How I would do it?

  1. In your header file, define an UIImageView.
  2. When your device is shaken, init the view with the right frame
  3. Load an image in that UIImageView.
  4. Add that UIImageView to the view that is currently shown.
  5. Create a NSTimer which has an interval of the time you want to show your image
  6. When the timer hits its interval, remove the imageview from the view.

I am not putting all kinds of code here, because you also supply no code whatsoever, but I think you can figure it out yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文