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;
  • 相关阅读:
    Template(模板)模式
    Android活动(Activity)创建及生命周期
    Android--SharedPreferences数据存储方案
    Adapter适配器模式--图解设计模式
    准时制生产(Just in Time,JIT)
    术语
    制造资源计划(Manufacturing Resource Planning,Mrp II)
    Angualr6表单提交验证并跳转
    Android PDA扫描枪广播接搜条码并使用
    Java统计代码行数
  • 原文地址:https://www.cnblogs.com/pengyunjing/p/5907727.html
Copyright © 2011-2022 走看看