提示框(UIAlertController)的使用。
添加出现在屏幕中间的提示框(也就是之前的UIAlertView):
UIAlertController * av = [UIAlertController alertControllerWithTitle:@"提示" message:@"请检查网络!" preferredStyle:(UIAlertControllerStyleAlert)];
// 添加 取消 按钮
[av addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击取消");
}]];
// 添加 确认 按钮 [av addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(@"点击确认"); }]];
// 添加 警告 按钮 [av addAction:[UIAlertAction actionWithTitle:@"警告" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { NSLog(@"点击警告"); }]];
// 添加 文本框 按钮 [av addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { NSLog(@"添加一个textField就会调用 这个block"); }]; //
[self presentViewController:av animated:YES completion:nil];
添加从底部弹出的提示框(也就是之前的UIActionSheet):
UIAlertController * av = [UIAlertController alertControllerWithTitle:@"提示" message:@"请检查网络!" preferredStyle:(UIAlertControllerStyleActionSheet)];
// 添加 取消 按钮
[av addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击取消");
}]];
// 添加 确认 按钮
[av addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击确认");
}]];
// 添加 警告 按钮
[av addAction:[UIAlertAction actionWithTitle:@"警告" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击警告");
}]];
[self presentViewController:av animated:YES completion:nil];
提示框(UIAlertController)的使用。的更多相关文章
- 选择提示框UIAlertController 和网络状态判断AFNetworking
// 选择提示框 DownloadView *vc = [[DownloadView alloc] initWithFrame:CGRectMake(, , SCREEN_WIDTH, SCREEN_ ...
- iOS -iOS9中提示框(UIAlertController)的常见使用
iOS 8 之前提示框主要使用 UIAlertView和UIActionSheet:iOS 9 将UIAlertView和UIActionSheet合二为一为:UIAlertController . ...
- Swift_IOS之提示框UIAlertController
import UIKit class ViewController: UIViewController ,UIActionSheetDelegate{ @IBAction func btn1(_ se ...
- 19. UIAlertController 提示框获取文本内容,打印控制台上
1.首先定义一个全局字符串变量,方便接收获取的文本内容 2. -(void)viewDidAppear:(BOOL)animated{ UIAlertController * alert = [UIA ...
- Swift - 告警提示框(UIAlertController)的用法
自iOS8起,苹果就建议告警框使用UIAlertController来代替UIAlertView.下面总结了一些常见的用法: 1,简单的应用(同时按钮响应Handler使用闭包函数) 1 2 3 ...
- iOS - UIAlertController三种显示提示框代码
UIAlertView在IOS 8以上版本已经过时了,官方推荐我们使用UIAlertController代替UIAlertView.UIActionSheet 1、UIAlertController显 ...
- iOS开发——UI基础-提示框
提示框的种类有很多,废话不多说,直接上代码 一.文本提示框 运行结果如下: 代码实现如下: @interface ViewController () // 添加方法 - (IBAction)add; ...
- WKWebView不显示提示框(Swift)
使用WKWebView的时候会出现明明自己做的一些页面有提示框, 为什么使用别人的页面提示框总是不显示, 其实很大部分原因是因为该提示框是通过JS调用的, 需要实现WKUIDelegate来进行监听 ...
- iOS:提示框(警告框)控件UIActionSheet的详解
提示框(警告框)控件2:UIActionSheet 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.它与导航栏类似,它继承自UIView. 风格类型: ...
随机推荐
- GridView中的GridView1_RowCommand事件
GridView1_RowCommand事件是GridView中生成事件时激发 比如说页面中有一个按钮给他设置CommandName属性 <asp:Button ID="btnCheH ...
- Android Studio Exception汇总
Android Studio 运行时出现 finished with non-zero exit value 2 错误分析 原因: 项目包含了两个相同包名的不同 project 或者 jar 举例: ...
- sublimetext 使用正则表达式匹配中文
[\x{4e00}-\x{9fa5}] ============================================= 参考资料 1.在javascript下正确的\x4e00-\x9fa ...
- Python 100道题深入理解
# -*- coding: utf-8 -*-# 题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?# 程序分析:可填在百位.十位.个位的数字都是1.2.3.4.组成所 ...
- ASP.NET MVC : Action过滤器(Filtering)
http://www.cnblogs.com/QLeelulu/archive/2008/03/21/1117092.html ASP.NET MVC : Action过滤器(Filtering) 相 ...
- moment.js 的简单应用
moment.js :时间处理的组件 例子:moment.html <!DOCTYPE html> <html> <head> <title>mome ...
- unity, terrain道出为obj
http://wiki.unity3d.com/index.php?title=TerrainObjExporter
- ASP.NET Web API 学习【转】
转自:http://www.cnblogs.com/babycool/p/3922738.html 来看看对于一般前台页面发起的get和post请求,我们在Web API中要如何来处理. 这里我使用J ...
- Mybatis知识点总结
---恢复内容开始--- Mybatis知识点总结 1.#{}和${}的区别是什么? 答:#{}的使用场景:在表的sql映射文件中如下使用: <mapper namespace="co ...
- EditText 自动格式化电话电话号码
需要格式化的格式为:xxx xxxx xxxx 有两种方式:1.为监听当前输入的长度,当长度为第四位,九位的时候,在原内容上追加空格.(from stackOverFlow)2.每次输入后,格式化当前 ...