zoukankan      html  css  js  c++  java
  • iOS之UIAlertView的使用

    UIAlertView:

    1.普通使用:

        //普通的alert

        UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];

        [av show];

    2.UIAlertView还可以设置其样式:

    如果可以输入账号与密码的样式:

        //普通的alert

        UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];

        [av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];//设置样式:明文与暗文

        [av show];

    3.判断用户点击了alert的哪个按钮的协议:

    //协议:alertView

    //判断用户点击了alert的那个按钮

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

    {

        if(buttonIndex == 0)

        {

            NSLog(@"you click no");

        }

        else

        {

            NSLog(@"you click yes");

        }

    }

    4.   常用方法总结:

    1. //根据被点击按钮的索引处理点击事件  
    2. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  
    3. {  
    4.     NSLog(@"clickButtonAtIndex:%d",buttonIndex);  
    5. }  
    6.   
    7. //AlertView已经消失时执行的事件  
    8. -(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex  
    9. {  
    10.     NSLog(@"didDismissWithButtonIndex");  
    11. }  
    12.   
    13. //ALertView即将消失时的事件  
    14. -(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex  
    15. {  
    16.     NSLog(@"willDismissWithButtonIndex");  
    17. }  
    18.   
    19. //AlertView的取消按钮的事件  
    20. -(void)alertViewCancel:(UIAlertView *)alertView  
    21. {  
    22.     NSLog(@"alertViewCancel");  
    23. }  
    24.   
    25. //AlertView已经显示时的事件  
    26. -(void)didPresentAlertView:(UIAlertView *)alertView  
    27. {  
    28.     NSLog(@"didPresentAlertView");  
    29. }  
    30.   
    31. //AlertView即将显示时  
    32. -(void)willPresentAlertView:(UIAlertView *)alertView  
    33. {  
    34.     NSLog(@"willPresentAlertView");  
  • 相关阅读:
    090828 H 小道理
    091031 T PowerShell Solution
    关注我们共有的家园,别让企鹅成为传说
    发布网站时自动切换connectionString
    bookmark: partitioned tables in sql server 2005
    it did suprise me a little bit..
    无法删除附加到事件上的匿名代理
    如何在自己工程项目中使用TouchJSON框架
    VMware 8安装苹果操作系统Mac OS X 10.7 Lion正式版
    Net线程间通信的异步机制
  • 原文地址:https://www.cnblogs.com/calence/p/5313555.html
Copyright © 2011-2022 走看看