zoukankan      html  css  js  c++  java
  • UIAlertView

    代码示例如下:

    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"这是一个警告框" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    
    [alert show];

    注意:如果按钮数超过两个,将会创建成如下样子:

    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"这是一个警告框" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"button1", @"button2", @"button3", @"button4", @"button5", nil];
        
    [alert show];

    如果高度超过屏幕,就会像tableView一样:

    添加一个按钮,返回的是此按钮的索引值
    - (NSInteger)addButtonWithTitle:(NSString *)title;   
    
    返回根据按钮索引按钮标题 
    - (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
    
    获取按钮数量
    @property(nonatomic,readonly) NSInteger numberOfButtons;
    
    设置将某一个按钮设置为取消按钮
    @property(nonatomic) NSInteger cancelButtonIndex;
    
    返回其他类型按钮第一个的索引值
    @property(nonatomic,readonly) NSInteger firstOtherButtonIndex;
    
    警告框是否可见
    @property(nonatomic,readonly,getter=isVisible) BOOL visible;
    
    显现警告框
    - (void)show;
    
    代码模拟点击按钮消失触发方法
    - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
    
    设置警告框风格
    @property(nonatomic,assign) UIAlertViewStyle alertViewStyle;
    
    风格的枚举如下:
    typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
        UIAlertViewStyleDefault = 0,//默认风格
        UIAlertViewStyleSecureTextInput,//密码输入框风格
        UIAlertViewStylePlainTextInput,//普通输入框风格
        UIAlertViewStyleLoginAndPasswordInput//账号密码框风格
    };
    
    这个方法设置文本输入框的索引
    - (UITextField *)textFieldAtIndex:(NSInteger)textFieldIndex;
    
    
    UIAlertViewDelegate的方法
    
    点击按钮时触发的方法
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
    
    将要展现警告框时触发的方法
    - (void)willPresentAlertView:(UIAlertView *)alertView;
    
    已经展现警告框时触发的方法
    - (void)didPresentAlertView:(UIAlertView *)alertView;
    
    警告框将要消失时触发的方法
    - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex;
    
    警告框已经消失时触发的方法
    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; 
    
    设置是否允许第一个按钮不是取消按钮
    - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView;
  • 相关阅读:
    触摸屏网站开发系列(一)-ios web App应用程序(ios meta)
    jQuery Mobile 入门教程
    html的视频插件 (转)
    网页布局流式布局
    2.05-random-uesr-proxy
    2.04-proxy-handler
    2.03-handler_openner
    2.02-request_header_two
    2.01-request_header
    1.03-get_params2
  • 原文地址:https://www.cnblogs.com/pengyunjing/p/5907727.html
Copyright © 2011-2022 走看看