什么是iOS应用程序的android.widget.Toast等价物? [英] What is the android.widget.Toast equivalent for iOS applications?

查看:150
本文介绍了什么是iOS应用程序的android.widget.Toast等价物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几个月前制作了Android应用程序。 Toast类对我来说非常有用。
我不需要考虑主线程和地方来显示它。我可以在任何地方展示它,然后离开它并自动消失。

I have made Android application a few months ago. The Toast class is very useful for me. I do not need to consider the main Thread and place to show it. Anywhere I can show it and just leave that and it is automatically disappeared.

Toast.makeToast(context, msg, Toast.LENGTH_SHORT).show();

就是这样。 ^^

iPhone怎么样?有像Toast这样的东西吗?只是显示消息,不需要关心它。它将自动消失。

What about iPhone? Is there something like the Toast? Just show message and do not need to care about it. It will be automatically disappeared.

推荐答案

UIKit中没有类开箱即用来执行此操作。但是创建一个可以提供此行为的类非常容易。

There is no class "out-of-the-box" in UIKit to do this. But it is quite easy to create a class that will offer this behavior.

您只需要创建一个继承自UIView的类。这个类将负责
- 创建你想要显示的内容,
- 在父视图层次结构中添加自己
- 使用计时器解雇自己。

You just have to create a class that inherit from UIView. This class will have the responsibility - to create what you want to display, - to add itself in parent view hierarchy - to dismiss itself using a timer.

您将能够像以下一样使用它:

You will be able to use it like :

[ToastView toastViewInView:myParentView withText:@"what a wonderful text"];

问候,
Quentin

Regards, Quentin

这篇关于什么是iOS应用程序的android.widget.Toast等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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