zoukankan      html  css  js  c++  java
  • iOS开篇——UI之UAlertView(提示框)

    创建提示框

     //创建提示框
        //标题  提示内容  代理对象  按钮
        
        UIAlertView * alertView = [[UIAlertView alloc]initWithTitle:@"警告" message:@"萨达姆已经做好战斗准备" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",@"不确定", nil];

     设置提示框样式

        alertView .alertViewStyle = UIAlertViewStylePlainTextInput;
        /*
         typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
         UIAlertViewStyleDefault = 0,
         UIAlertViewStyleSecureTextInput,   密文输入
         UIAlertViewStylePlainTextInput,    明文输入
         UIAlertViewStyleLoginAndPasswordInput  明文+密文
         } __TVOS_PROHIBITED;
         */

    让alertView显示出来

    [alertView show];

    设置代理 实现协议方法

    alertView.delegate = self;
    #pragma mark - UIAlertViewDelegate
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        if (buttonIndex == 0) {
            NSLog(@"点击了取消");
            NSLog(@"%@",[alertView textFieldAtIndex:0].text);
        }else{
            NSLog(@"点击了确定");
        }
    }

    iOS9之后不建议使用 

    UIAlertController+UIAlertControllerStyleAlert 也可以实现同样功能

  • 相关阅读:
    Python-02 可视化之tkinter介绍
    Python-01矩阵、数组和列表等的总结
    嵌入式文件IO实验
    Linux 学习
    linux 学习
    Linux学习
    Linux学习
    Linux 学习
    Linux 学习
    Linux 用户权限学习
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990242.html
Copyright © 2011-2022 走看看