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];
  • 相关阅读:
    初拾Java(问题一:404错误,页面找不到)
    新年新气象--总结过去,展望未来
    接口测试[整理]
    [转]SVN-版本控制软件
    浅谈黑盒测试和白盒测试
    Bug管理工具的使用介绍(Bugger 2016)
    P2805/BZOJ1565 [NOI2009]植物大战僵尸
    近期学习目标
    P3643/BZOJ4584 [APIO2016]划艇
    P5344 【XR-1】逛森林
  • 原文地址:https://www.cnblogs.com/weipeng168/p/5220366.html
Copyright © 2011-2022 走看看