UIActionSheet/ UIAlaterView/UIAlertController
2016-11-26 14:20
447 查看
UIActionSheet/ UIAlaterView 的区别是,
1 一个在屏幕底部弹出, 一个在屏幕正中间弹出.
2 按钮的序号不同. UIActionSheet 按钮的序号, 是从上往下, 依次 0,1,2…. UIAlaterView 按钮的序号 是 cancelButtonTitle是0 otherButtonTitles是 从1,2,3…
// 弹出来alertview ios7 以后中的另一种写法
//UIAlertControllerStyleAlert 可以选择是在底部,还是屏幕中间
UIAlertController *vc = [UIAlertController alertControllerWithTitle:@”提示” message:@”指纹识别” preferredStyle:UIAlertControllerStyleAlert];
(IBAction)logout:(id)sender {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@”提示” delegate:self cancelButtonTitle:@”取消” destructiveButtonTitle:@”确定” otherButtonTitles:nil, nil];
//显示
[sheet showInView:self.view];
遵守代理 实现代理方法, 可以对点击按钮后进行对应操作.
在屏幕正中央,弹出一个提示框,
可以是两个选项, 也可以是三个选项.
UIAlaterView 按钮的序号(buttonIndex) 是 cancelButtonTitle(不退出)是0 otherButtonTitles是 从1,2,3…
代理方法
1 一个在屏幕底部弹出, 一个在屏幕正中间弹出.
2 按钮的序号不同. UIActionSheet 按钮的序号, 是从上往下, 依次 0,1,2…. UIAlaterView 按钮的序号 是 cancelButtonTitle是0 otherButtonTitles是 从1,2,3…
// 弹出来alertview ios7 以后中的另一种写法
//UIAlertControllerStyleAlert 可以选择是在底部,还是屏幕中间
UIAlertController *vc = [UIAlertController alertControllerWithTitle:@”提示” message:@”指纹识别” preferredStyle:UIAlertControllerStyleAlert];
//添加按钮
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; [vc addAction:action1];
//红色字体的
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { NSLog(@"queding"); }]; [vc addAction:action2]; [self presentViewController:vc animated:YES completion:nil];
通讯录 04 通讯录注销 第4分钟
在底部弹出一个警示框, 用于给用户提供选项, 如QQ 点击退出时在底部弹出的 确定/ 取消/ 退出后接收消息.(IBAction)logout:(id)sender {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@”提示” delegate:self cancelButtonTitle:@”取消” destructiveButtonTitle:@”确定” otherButtonTitles:nil, nil];
//显示
[sheet showInView:self.view];
遵守代理 实现代理方法, 可以对点击按钮后进行对应操作.
pragma mark - actionSheet的代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { //点了确定按钮 排序,从上往下 0,1,2….. [self.navigationController popViewControllerAnimated:YES]; } }
在屏幕正中央,弹出一个提示框,
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示 " message:@"退出QQ ?" delegate:self cancelButtonTitle:@"不退出" otherButtonTitles:@"退出",@"暂停", nil]; [alertView show];
可以是两个选项, 也可以是三个选项.
UIAlaterView 按钮的序号(buttonIndex) 是 cancelButtonTitle(不退出)是0 otherButtonTitles是 从1,2,3…
代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"点击了%ld",(long)buttonIndex); }
相关文章推荐
- UIAlertController  VS  UIAlertView and UIActionSheet
- iOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
- IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
- IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
- swift学习之-- UIAlertVIewController - uiactionsheet
- UIAlertController(UIAlertView && UIActionSheet)
- UIAlertController UIAlertAction (UIAlertView, UIActionSheet)
- UIAlertController UIAlertAction (UIAlertView, UIActionSheet)(最好)
- UIAlertController replaces the UIActionSheet and UIAlertView
- 提醒用户_UIAlertview/UIActionsheet
- iOS8 UIAlertController 创建UIAlertView以及UIActionSheet
- 介绍UIALertView和UIActionSheet的用法。
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- MMPopupView(自定义UIAlertView、UIActionSheet、UIDatePicker)
- iOS UIAlertView和UIActionSheet的用法
- 学习IOS开发UI篇--UIAlertView/UIActionSheet
- UIAlertView及UIActionSheet 在ios8极其以下版本的兼容问题解决方案
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- iOS学习笔记—— UIAlertView 和 UIActionSheet 的使用
- 【学习ios之路:UI系列】UIAlertView. UIActionSheet 和 UIAlertController