UIAlertView 基础篇

来源:互联网 发布:网络运维绩效考核 编辑:程序博客网 时间:2024/06/04 20:13

         属性

         title:标题

         message:内容

         numberOfButtons:获取按钮个数

         cancelButtonIndex:设置将某一个按钮设置为取消按钮

         firstOtherButtonIndex返回其他类型按钮第一个的索引值


         visible:警告框是否可见

         alertViewStyle:警告框模式 (UIAlertViewStyleDefault,UIAlertViewStyleSecureTextInput,UIAlertViewStylePlainTextInput,UIAlertViewStyleLoginAndPasswordInput)

         方法:

         - (instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message delegate:(nullable id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(nullable NSString *)cancelButtonTitle otherButtonTitles:(nullable NSString *)otherButtonTitles;初始化方法,可以设置标题,内容,住按钮,和其他按钮

         - (id)initWithFrame:(CGRect)frame;设置位置大小

         - (NSInteger)addButtonWithTitle:(nullable NSString *)title;添加一个按钮并返回该按钮的索引

         - (nullable NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;根据按钮索引返回标题

         - (void)show;展示警告框

         - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;模拟点击按钮消失触发的方法

         - (nullable UITextField *)textFieldAtIndex:(NSInteger)textFieldIndex;设置文本框输入的索引

       代理方法

         - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;点击按钮时触发的方法

         - (void)alertViewCancel:(UIAlertView *)alertView;点击home键调用的方法

         - (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;设置是否允许第一个按钮不是取消按钮

          

0 0
原创粉丝点击