zoukankan      html  css  js  c++  java
  • iOS8.0前后关于alertView和actionSheet

    8.0之前两个控件分别创建

    8.0之后两个控件统一由UIAlertController管理

    例:

    UIAlertController * alert =[UIAlertController alertControllerWithTitle:@"提示消息" message:@"账号密码有误" preferredStyle:UIAlertControllerStyleAlert];

    其中preferredStyle的定义是:

    typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {

        UIAlertControllerStyleActionSheet = 0,

        UIAlertControllerStyleAlert

    } NS_ENUM_AVAILABLE_IOS(8_0);

    通过改变preferredStyle来决定使用alertView还是actionSheet

     

    定义alertAction并添加到alert中

    UIAlertAction * defaultAction = [UIAlertAction actionWithTitle:@"请重新输入" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)

                    {

           //在block中写点击之后要做的事情

                        ((ViewController*)vc).usernameTextField.text = @"";

                        ((ViewController*)vc).passwordTextField.text = @"";

                    }];

    [alert addAction:defaultAction];

    如果不是在VC文件中而是在请求数据类似的其他文件中触发了alertView,在对原VC进行操作时,要将原VC作为参数传过来,并在头文件导入原VC,并将传过来的参数强转,再进行操作。

  • 相关阅读:
    阻止事件传播的常用方法
    原生JS获取元素的位置与尺寸
    FileReader 与canvas结合使用显示图片
    dot.js使用心得
    时间格式转换
    JS对象操作
    vue-awesome-swipe 基于vue使用的轮播组件 使用(改)
    vscode 插件推荐
    chrome 发送请求出现:Provisional headers are shown 提示
    手机端
  • 原文地址:https://www.cnblogs.com/J-yq/p/5307197.html
Copyright © 2011-2022 走看看