UITextField * textFiled1;
UITextField * textFiled2;
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"请输入" message:@"账号和密码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
alert.tag = 100;
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
textFiled1 = [alert textFieldAtIndex:0];
textFiled1.keyboardType = UIKeyboardTypeNumberPad;
textFiled2 = [alert textFieldAtIndex:1];
[alert show];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView.tag == 100 && buttonIndex == 1) {
self.lab1.text = textFiled1.text;
self.lab2.text = textFiled2.text;
}
}
原文地址:http://blog.csdn.net/heyachaodeios/article/details/45197435