当前位置:网站首页>[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
2022-07-06 08:50:00 【关于小司】
文章目录
UIAlertController
UIAlertController是iOSUI界面的等待提示框控件
注意
- 在iOS 9.0之后 之前的提示对话框 UIAlertView 被弃用
当我们打出 UIAlertView 对象的时候
- 包括一些视频讲解的时候也是把Xcode的编译环境变成了 iOS 9 以下
- 在iOS 9 之后 Xcode 提供了新的UIAlertController 对象来创建对话提示框对象
UIAlertController 的用法
- 创建一个警告提示框对象
- 养成合成存取方法的方法[email protected]
@interface ViewController : UIViewController<UIAlertViewDelegate> {
// 警告框视图对象
UIAlertController* _alertView ;
// 等待提示对象
//当下载或者加载较大的文件时候显示此控件,处于提升等待状态
}
@property(retain, nonatomic) UIAlertController* alertView;
@end
- 同步属性和成员变量
@implementation ViewController// 实现部分
@synthesize alertView = _alertView;
// 等待提示框 此处可不看
@synthesize activityIndicator = _activityIndicator;
- 加一个button使用同一个事件函数
可循环创建 可单独创建 - 循环创建的原因是我把 提示对话框 And 等待提示器 两个按钮在一起创建了
- 按钮创建看另一篇博客 UIBUtton的创建
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(100, 100 + 100 * i, 100, 40);
[btn setTitle:@"警告对话框架" forState:UIControlStateNormal];
// 因为我是循环创建 把标志设置 为了button 事件的引用
btn.tag = 100 + i
- 添加button事件 函数
- 带参数的原因是我们不止一个button
[btn addTarget:self action:@selector(pressBtn :)
forControlEvents:UIControlEventTouchUpInside];
iOS9.0. 以上UIAlertController 创建方法
- 1) iOS 9 之后的 UIAlertController 用法
提示的题目和内容:
_alertView = [UIAlertController alertControllerWithTitle:@"警告"
message:@"手机被我入侵,即将关机,速速打钱"
preferredStyle:UIAlertControllerStyleAlert];
参数1:警告 --是我们提示框的标题
参数2:手机被我入侵,即将关机,速速打钱" ---提示内容
- 2) 添加选项
- 选项一:
UIAlertAction* sure = [UIAlertAction actionWithTitle:@"确定"
style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)
{
NSLog(@"确定");
}];
- 选项二 —cancle
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"取消"
style:UIAlertActionStyleCancel handler:nil];
- 3)添加选项到视图_alertView
- _alertView 是我们创建的提示框视图
[_alertView addAction:sure];
[_alertView addAction:cancel];
- 显示视图
// 显示视图
[self presentViewController:_alertView animated:YES
completion:nil];
效果

UIActivityIndicatorView
- 等待提示对象 --当下载或者加载较大的文件时候显示此控件,处于提升等待状态
// 等待提示对象
//当下载或者加载较大的文件时候显示此控件,处于提升等待状态
UIActivityIndicatorView* _activityIndicator;
UIActivityIndicatorView的创建
- 合成存取方法
@property(retain, nonatomic) UIActivityIndicatorView* activityIndicator;
- 同步属性和成员变量
@synthesize activityIndicator = _activityIndicator;
- 创建button
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(100, 100 + 100 * i, 100, 40);
[btn setTitle:@"提示对话框" forState:UIControlStateNormal];
btn.tag = 100 + i;
[btn addTarget:self action:@selector(pressBtn :) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
- 添加 button 事件
- 等待指示器 宽 高是不可变更的
_activityIndicator = [[UIActivityIndicatorView alloc]
initWithFrame:CGRectMake(100, 300, 80, 80)] ;
- 等待指示器点击变成什么颜色
self.view .backgroundColor = [UIColor whiteColor];
[self.view addSubview:_activityIndicator];
//启动动画屏显示
[_activityIndicator startAnimating];
效果

- 我们点击提示对话框的时候 就会出现图中的圈圈
等待对话框的停用
当我们不需要这个效果的时候,输入这行代码即可不显示动画
//停止等待对话框
[_activityIndicator stopAnimating];
边栏推荐
- TP-LINK 企业路由器 PPTP 配置
- Light of domestic games destroyed by cracking
- gcc动态库fPIC和fpic编译选项差异介绍
- Leetcode: Sword Finger offer 42. Somme maximale des sous - tableaux consécutifs
- Export IEEE document format using latex
- C language double pointer -- classic question type
- LeetCode:124. 二叉树中的最大路径和
- [NVIDIA development board] FAQ (updated from time to time)
- @JsonBackReference和@JsonManagedReference(解决对象中存在双向引用导致的无限递归)
- torch建立的网络模型使用torchviz显示
猜你喜欢

【嵌入式】Cortex M4F DSP库

Using pkgbuild:: find in R language_ Rtools check whether rtools is available and use sys The which function checks whether make exists, installs it if not, and binds R and rtools with the writelines

C語言雙指針——經典題型

vb. Net changes with the window, scales the size of the control and maintains its relative position

After PCD is converted to ply, it cannot be opened in meshlab, prompting error details: ignored EOF

Process of obtaining the electronic version of academic qualifications of xuexin.com

Compétences en mémoire des graphiques UML

生成器参数传入参数

Delay initialization and sealing classes

Indentation of tabs and spaces when writing programs for sublime text
随机推荐
Mobile phones and computers on the same LAN access each other, IIS settings
sublime text没关闭其他运行就使用CTRL+b运行另外的程序问题
企微服务商平台收费接口对接教程
电脑清理,删除的系统文件
[embedded] print log using JLINK RTT
Detailed explanation of dynamic planning
LeetCode:236. 二叉树的最近公共祖先
MYSQL卸载方法与安装方法
MongoDB 的安装和基本操作
LeetCode:124. 二叉树中的最大路径和
[NVIDIA development board] FAQ (updated from time to time)
Leetcode: Sword finger offer 42 Maximum sum of continuous subarrays
egg. JS directory structure
Purpose of computer F1-F12
被破解毁掉的国产游戏之光
pytorch训练好的模型在加载和保存过程中的问题
sublime text的编写程序时的Tab和空格缩进问题
软件卸载时遇到trying to use is on a network resource that is unavailable
Image,cv2读取图片的numpy数组的转换和尺寸resize变化
JVM quick start