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 也可以实现同样功能

  • 相关阅读:
    287. Find the Duplicate Number
    基本排序算法实现
    Java内存模型
    JVM之垃圾收集器与内存分配回收策略(二)
    Java并发编程基础——同步
    二维数组的查找问题
    Maven整合SSM测试
    Mysql基础
    SpringMVC之Controller和参数绑定
    Spring+SpringMVC+Mybatis整合
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990242.html
Copyright © 2011-2022 走看看