• 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");  
  • 相关阅读:
    [zz] 从VMM中终止GUEST OS中运行进程
    [zz]Linux流量监控工具 – iftop (最全面的iftop教程)
    [zz]Ubuntu终端下Nethogs网络流量监控工具
    AtomicBoolean运用
    JDK中的URLConnection参数详解
    java读取文本文件数据
    tomcat时区设置
    java的upload
    java复习(set 、list、map)
    NIO学习笔记1
  • 原文地址:https://www.cnblogs.com/calence/p/5313555.html
Copyright © 2020-2023  润新知