zoukankan      html  css  js  c++  java
  • UIAlertView 解读

    直接看代码:

    IOS5新增:
       typedef enum {
        UIAlertViewStyleDefault = 0,
        UIAlertViewStyleSecureTextInput,
        UIAlertViewStylePlainTextInput,
        UIAlertViewStyleLoginAndPasswordInput
    } UIAlertViewStyle;

    - (IBAction)click3:(id)sender {
           UIAlertView *message = [[UIAlertView alloc]  
          initWithTitle:@"UIAlertViewStyleLoginAndPasswordInput" message:nil delegate:self
          cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue", nil];

         [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

        UITextField *loginFieldText = [message textFieldAtIndex:0];  //系统最多允许2个输入框,获取输入框按序号0、1来获取
        loginFieldText.placeholder = @"请输入用户名";

         //[message setNumberOfRows:2];  //实际上可以这样设置,指示SDK在5中还没暴露出来,设置之后每个按钮就是纵向排列的了

         [message show];
     }

    #pragma UIAlertView Delegate

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
              if (UIAlertViewStyleLoginAndPasswordInput == alertView.alertViewStyle) {
                      UITextField *nameTextField = [alertView textFieldAtIndex:0];
                      UITextField *pwdTextField = [alertView textFieldAtIndex:1];
                       NSLog(@"name = %@, pwd = %@, buttonIndex = %d",nameTextField.text,pwdTextField.text,buttonIndex);
              }else if (UIAlertViewStylePlainTextInput == alertView.alertViewStyle) {
                      UITextField *plainTextField = [alertView textFieldAtIndex:0]; 
    NSLog(@"plainTextField.text = %@, buttonIndex = %d",plainTextField.text,buttonIndex);
             }else if (UIAlertViewStyleSecureTextInput == alertView.alertViewStyle) {
                     UITextField *secureTextField = [alertView textFieldAtIndex:0]; NSLog(@"secureTextField.text = %@, buttonIndex = %d",secureTextField.text,buttonIndex); 

             }else {
                  NSLog(@"buttonIndex = %d",buttonIndex);
             }
    }

    //这个很少用到目前起码
    - (void)alertViewCancel:(UIAlertView *)alertView { NSLog(@"alertViewCancel"); }

    //将要显示alertView时调用
     - (void)willPresentAlertView:(UIAlertView *)alertView{ NSLog(@"willPresentAlertView"); }

    //已经显示alertView时调用
     - (void)didPresentAlertView:(UIAlertView *)alertView { NSLog(@"didPresentAlertView"); }

    //将要隐藏alertView时调用
    - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {        NSLog(@"willDismissWithButtonIndex"); }

    //已经隐藏alertView时调用
     - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { NSLog(@"didDismissWithButtonIndex"); }

    //每次编辑输入框时会调用
     // Called after edits in any of the default fields added by the style - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView { return YES; }
  • 相关阅读:
    ATA/SATA/SCSI/SAS/FC总线简介
    RAID卡
    解读Gartner《2015年度新兴技术成熟度曲线报告》
    linux 下 取进程占用内存(MEM)最高的前10个进程
    网站用域名能访问,用域名IP不能访问的原因分析
    iis7下iis安全狗不能用怎么办(安装iis6兼容性)
    4M宽带一般最大的下载速度是多少?
    U盘安装操作系统
    windows7实现打印机共享的方法
    windows7系统下如何安装windows xp系统(无法识别硬盘,删除隐藏分区)
  • 原文地址:https://www.cnblogs.com/cnsec/p/11515845.html
Copyright © 2011-2022 走看看