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];
  • 相关阅读:
    Kafka调试入门(一)
    java笔记十五——多线程
    java笔记十四——初始集合源码
    java笔记十二——集合总结
    java笔记十一——异常
    java笔记十——大数类和日期类
    java笔记九——Object类与String类
    java笔记八——面向对象(三)
    java笔记七——面向对象(二)
    java笔记六——面向对象(一)
  • 原文地址:https://www.cnblogs.com/weipeng168/p/5220366.html
Copyright © 2011-2022 走看看