首页 > 移动平台 > 详细

iOS中UIAlertView的使用方法

时间:2015-04-09 10:35:18      阅读:242      评论:0      收藏:0      [点我收藏+]


    UIAlertView * alertView=[[UIAlertView alloc]initWithTitle:nil

                                                  message:@"真的要退出?"

                                                 delegate:self

                                        cancelButtonTitle:@"确定"

                                        otherButtonTitles:@"取消", nil];

    alertView.tag=11;

    [alertView show];

然后实现

UIAlertViewDelegate的代理方法

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

//执行的代码

}

2.3带输入框的Alert

//登陆弹出框:一个文本输入框,一个密码框 
UIAlertView *alertView = [[UIAlertView alloc] 
                              initWithTitle:@"Password" message:@"Please enter your credentials" delegate:self 
                              cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
//设置AlertView的样式 
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput]; 
[alertView show]; 

//登陆弹出框:一个文本输入框,一个密码框
UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:@"Password" message:@"Please enter your credentials" delegate:self
                              cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
//设置AlertView的样式
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
[alertView show];


 UIAlertViewStylePlainTextInput 添加一个普通输入框 
 UIAlertViewStyleSecureTextInput  密码输入框
 UIAlertViewStyleLoginAndPasswordInput  普通输入框加密码输入框

-(void)alertView : (UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
2
3        //得到输入框
4        UITextField *tf=[alertView textFieldAtIndex:0];
5 }



iOS中UIAlertView的使用方法

原文:http://blog.csdn.net/yangchen9931/article/details/44955407

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!