一开始在刚接触到Alert和ActionSheet的时候,经常傻傻分不清楚,好不容易用习惯了,苹果又给合并了,好在用起来也不困难,到底哪个好呢?见仁见智吧!
现在稍微介绍一下怎么用。
1.初始化,一般用这个类方法

最后一个参数是个枚举类型,有两个值,分别就是Alert和ActionSheet

2.推出AlertController
因为是个Controller,所以就不能单纯的show一下了。要用推出一般Controller的方法来解决。

Alert和ActionSheet的初步显示效果分别是:


3.添加自定义的格式(取消,确认...)

style默认有三个风格
Alert和ActionSheet的显示效果分别是:

4.添加文本输入框 (只能在Alert上加,ActionSheet上不能添加)

注意:添加textField要在推出controller之前
5.添加文本输入框的监听方法

常用的方法就这些了,很简单,看一遍就会!!!加油啦!!!