虽然被抛弃了,还是要用所以还是研究了一下
下面就一起看一下,我把所有的UIAlertView的系统方法,以及系统属性全部弄了一遍,希望对大家有帮助
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"你好啊" message:@"取消" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"啊", nil];
alert.frame = CGRectMake(0, 0, WIDTH, 300);
alert.delegate = self;
alert.title = @"重新定义title";
alert.message = @"重新定义message";
[alert addButtonWithTitle:@"不是创建的"];
[alert addButtonWithTitle:@"不是创建的2"];
NSLog(@"number Of Buttons :%ld",alert.numberOfButtons);//获取当前button的个数
//获取指定索引的按钮标题
NSLog(@"buttonTitleAtIndex1:%@",[alert buttonTitleAtIndex:0]);//title @"啊"
NSLog(@"buttonTitleAtIndex2:%@",[alert buttonTitleAtIndex:1]);//@"ok"
//获取取消按钮的索引
NSLog(@"cancelButtonIndex:%ld",alert.cancelButtonIndex);
//获取第一个其他按钮的索引
NSLog(@"firstOtherButtonIndex:%ld",alert.firstOtherButtonIndex);
NSLog(@"visible:%d",alert.visible);
/*
UIAlertViewStyleDefault = 0,
UIAlertViewStyleSecureTextInput, 加密输入框
UIAlertViewStylePlainTextInput, 输入框
UIAlertViewStyleLoginAndPasswordInput 账号已经密码输入框
*/
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
[alert show];
// [alert dismissWithClickedButtonIndex:1 animated:YES];//执行点击index为1的button
UITextField * text = [[UITextField alloc] init];
// text.placeholder = @"自己的textfield";
text = [alert textFieldAtIndex:0]; // 获取index为0的textfield
NSLog(@"%@",text.placeholder);
下面是代理方法
#pragma mark ----------------代理方法们,等待朕的君临天下吧------------
//根据被点击按钮的索引处理点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
NSLog(@"我是0");
}
}
//AlertView已经消失时执行的事件
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"不,我不想消失,消失了");
}
//ALertView即将消失时的事件
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"即将消失了");
}
//AlertView的取消按钮的事件
-(void)alertViewCancel:(UIAlertView *)alertView
{
NSLog(@"取消按钮");
//
}
//AlertView已经显示时的事件
-(void)didPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"显示");
}
//AlertView即将显示时
-(void)willPresentAlertView:(UIAlertView *)alertView
{
NSLog(@"即将显示");
}
如果你还需要别的功能,请自定制吧!