zoukankan      html  css  js  c++  java
  • 提示框(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];
  • 相关阅读:
    实习感悟——从用户中来,到用户中去
    FineUI PK DWZ
    Java入门到精通——工具篇之Maven概述
    信息论的熵
    菜鸟学习Hibernate——一对多关系映射
    StyleCop学习笔记——默认的规则
    StyleCop学习笔记——自定义规则
    StyleCop学习笔记——初识StyleCop
    好博客收藏
    菜鸟学习Hibernate——简单的增、删、改、查操作
  • 原文地址:https://www.cnblogs.com/weipeng168/p/5220366.html
Copyright © 2011-2022 走看看