zoukankan      html  css  js  c++  java
  • UIAlert的使用

    1 UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"密码验证"
     2 
     3                                                     message:@"请输入管理员密码"
     4 
     5                                                    delegate:nil
     6 
     7                                           cancelButtonTitle:@"cancel"
     8 
     9                                           otherButtonTitles:@"OK", nil];
    10 
    11     //设置代理
    12 
    13     alert.delegate = self;
    14 
    15  
    16 
    17     // 基本输入框,显示实际输入的内容
    18 
    19     alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    20 
    21     // 用户名,密码登录框
    22 
    23     //    alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    24 
    25     // 密码形式的输入框,输入字符会显示为圆点
    26 
    27     //    alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
    28 
    29     
    30 
    31     //设置输入框的键盘类型
    32 
    33     UITextField *tf = [alert textFieldAtIndex:0];
    34 
    35     tf.keyboardType = UIKeyboardTypeNumberPad;
    36 
    37     
    38 
    39     UITextField *tf2 = nil;
    40 
    41     if (alert.alertViewStyle == UIAlertViewStyleLoginAndPasswordInput) {
    42 
    43         // 对于用户名密码类型的弹出框,还可以取另一个输入框
    44 
    45         tf2 = [alert textFieldAtIndex:1];
    46 
    47         tf2.keyboardType = UIKeyboardTypeASCIICapable;
    48 
    49     }
    50 
    51     
    52 
    53     // 取得输入的值
    54 
    55     NSString* text = tf.text;
    56 
    57     NSLog(@"INPUT:%@", text);
    58 
    59     if (alert.alertViewStyle == UIAlertViewStyleLoginAndPasswordInput) {
    60 
    61         // 对于两个输入框的
    62 
    63         NSString* text2 = tf2.text;
    64 
    65         NSLog(@"INPUT2:%@", text2);
    66 
    67     }
    68 
    69     
    70 
    71     
    72 
    73     [alert show];
    74 
    75   //点击事件调用UIAlert代理方法
  • 相关阅读:
    redis系列之------过期策略
    总结与期盼
    服务不可用排查思路
    Spring Boot Starters到底怎么回事?
    redis系列之------主从复制
    redis系列之------对象
    redis系列之------数据库
    DirectX11 With Windows SDK--00 目录
    DirectX11 With Windows SDK--34 位移贴图
    DirectX11 With Windows SDK--33 曲面细分阶段(Tessellation)
  • 原文地址:https://www.cnblogs.com/yxt9322yxt/p/4755610.html
Copyright © 2011-2022 走看看