- (IBAction)AlertView:(id)sender {
UIAlertView *alerview=[[UIAlertView alloc]initWithTitle:@"提示" message:@"这是一个警告框" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
// [alerview addButtonWithTitle:@"不确定"];//动态添加子按钮
NSLog(@"%d",alerview.visible);//是否可见
NSLog(@"%d",alerview.numberOfButtons);//警告框的子按钮的个数
NSLog(@"%@",[alerview buttonTitleAtIndex:0]);//指定索引的按钮的标题
/**
* UIAlertViewStyleDefault 基本样式
*UIAlertViewStyleSecureTextInput 带一个密文输入框
*UIAlertViewStylePlainTextInput 带一个明文输入框
*UIAlertViewStyleLoginAndPasswordInput 带有明文+密文样式输入框的警告框
*/
alerview.alertViewStyle=UIAlertViewStyleLoginAndPasswordInput;
UITextField *loginTF=[alerview textFieldAtIndex:0];//获取登陆的输入框
UITextField *password=[alerview textFieldAtIndex:1];//密码的输入框
loginTF.placeholder=@"账号";
password.placeholder=@"密码";
[alerview show];
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
//NSLog(@"警示框已经移除");
}
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
// NSLog(@"警示框将要移除");
}
//根据参数buttonIndex来判断点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
{
NSLog(@"取消");
break;
}
case 1:
{
NSLog(@"确定");
break;
}
case 2:
{
NSLog(@"3");
break;
}
case 3:
{
NSLog(@"4");
break;
}
default:
break;
}
}
//按钮组