温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

UIAlertView   提示控件

发布时间:2020-07-13 00:54:01 来源:网络 阅读:147 作者:缘起愿落 栏目:开发技术


服从UIAlertViewDelegate 协议



       
      Title : 标题
       message : 提示消息
      delegate  : 代理
      cancelButtonTitle : 取消显示
      otherButtonTitles : 其他按钮显示文字,只给出按钮显示的文字即可,可多个
       


UIAlertView * alertView =  [[UIAlertView alloc]initWithTitle:@"警告"
                                                             message:@"手机号码输入错误"
                                                            delegate:self
                                                   cancelButtonTitle:@"取消"
                                                   otherButtonTitles:@"确定",@"sure", nil];
     

UIAlertViewStyleDefault = 0,            默认
     

UIAlertViewStyleSecureTextInput,         密码
 

UIAlertViewStylePlainTextInput,          输入框
  

UIAlertViewStyleLoginAndPasswordInput       登录,密码
        
        
        alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
        
        [alertView show];         让alertView 弹出
        
        [alertView release];







     当点击 alertView  上 button时 触发的方法.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    取消按钮的buttonindex 为 0
    其他的按钮从左往右依次 + 1 ;
  
    
  通过switch..case 匹配是哪一个按钮按下
    switch (buttonIndex) {
        case 0:
            NSLog(@"取消");
            break;
        case 1:
            NSLog(@"确定");
            break;
        case 2:
            NSLog(@"sure");
            break;
        default:
            break;
    }
}




当我们取消一个视图(如。用户单击按钮)。这不是用户单击取消按钮时调用。

如果没有定义的委托,我们模拟点击取消按钮

- (void)alertViewCancel:(UIAlertView *)alertView;


- (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;

编辑的任何违约后称为字段添加的风格







向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI