当前位置:网站首页>[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];
边栏推荐
- marathon-envs项目环境配置(强化学习模仿参考动作)
- Sublime text using ctrl+b to run another program without closing other runs
- LeetCode:剑指 Offer 03. 数组中重复的数字
- PC easy to use essential software (used)
- 【嵌入式】使用JLINK RTT打印log
- The harm of game unpacking and the importance of resource encryption
- Excellent software testers have these abilities
- vb. Net changes with the window, scales the size of the control and maintains its relative position
- Chrome浏览器的crash问题
- Using C language to complete a simple calculator (function pointer array and callback function)
猜你喜欢

生成器参数传入参数

Mobile phones and computers on the same LAN access each other, IIS settings

Detailed explanation of dynamic planning

Warning in install. packages : package ‘RGtk2’ is not available for this version of R

ROS compilation calls the third-party dynamic library (xxx.so)

Excellent software testers have these abilities

vb.net 随窗口改变,缩放控件大小以及保持相对位置

Fairguard game reinforcement: under the upsurge of game going to sea, game security is facing new challenges

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
![[MySQL] limit implements paging](/img/94/2e84a3878e10636460aa0fe0adef67.jpg)
[MySQL] limit implements paging
随机推荐
如何进行接口测试测?有哪些注意事项?保姆级解读
JS pure function
egg. JS directory structure
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
【剑指offer】序列化二叉树
Indentation of tabs and spaces when writing programs for sublime text
Variable length parameter
opencv+dlib实现给蒙娜丽莎“配”眼镜
Browser thread
swagger设置字段required必填
TDengine 社区问题双周精选 | 第三期
hutool优雅解析URL链接并获取参数
LeetCode:673. 最长递增子序列的个数
Trying to use is on a network resource that is unavailable
Detailed explanation of dynamic planning
Roguelike game into crack the hardest hit areas, how to break the bureau?
[MySQL] limit implements paging
Screenshot in win10 system, win+prtsc save location
The harm of game unpacking and the importance of resource encryption