zoukankan      html  css  js  c++  java
  • 警告视图及操作表单在xcode7.0中的使用

    警告视图(alert)及操作表单(action sheet)都用于向用户提供反馈。(模态视图)

    操作表单:要求用户在两个以上选项之间做出选择。操作表单从屏幕底部出现,显示一系列按钮供用户选择。用户必须点击其中一个按钮之后才能继续使用应用程序。操作表单通常用于向用户确认有潜在危险的或者无法撤销的操作,比如删除对象。

    警告视图:以圆角矩形的形式出现在屏幕中央。与操作表单类似,警告视图也要求用户必须作出一个回应,然后才能继续使用应用程序。警告视图通常用于通知用户发生了一些重要的或者不寻常的事情。与操作表单不同,警告视图可以只显示一个按钮,但是如果需要接受多个回应的话,也允许显示多个。

    使用方式如下代码:

        NSString *title = @"A short Title is Best";
        NSString *message = @"A message should be a short, complete sentence";
        NSString *cancelButtonTitle = @"Cancel";
        NSString *otherButtonTitle = @"OK";
        
        //警告框
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
        
        //添加输入框(警告框才具备)
        [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
            // 可以对textField进行定制,如修改背景色
            textField.backgroundColor = [UIColor orangeColor];
        }];
        
    //    //操作表单
    //    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
        
        
        //create the actions
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"Cancel action occured.");
        }];
        
        UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"Other action occured.");
        }];
        
        [alertController addAction:cancelAction];
        [alertController addAction:otherAction];
        
        //显示
        [self presentViewController:alertController animated:YES completion:nil];
  • 相关阅读:
    SQL常用关键字
    SQL 笔记1,left join,group by,having
    SpringIDE的安装
    一些有用的书籍,也许需要看看
    执行力
    Q12问题
    WebCollector Cookbook (WebCollector中文文档):
    SSM配置文件
    wkhtmltopdf Windows下 测试demo 成功
    html2pdf 中文支持问题
  • 原文地址:https://www.cnblogs.com/smile-smile/p/5358164.html
Copyright © 2011-2022 走看看