一下示例展示了UIAlertView中加入输入框的方法:
-(void)showAlterDlg{
UIAlertView *passwordAlert = [[UIAlertView alloc] initWithTitle:@”请输入你的手机号”
message:@”系统会发送初始密码短信\n\n\n”
delegate:self
cancelButtonTitle:@”取消”
otherButtonTitles:@”确定”, nil];
UITextField *passwordField = [[UITextField alloc] initWithFrame:CGRectMake(12,80,260,30)];
passwordField.borderStyle = UITextBorderStyleBezel;
passwordField.placeholder = @”手机号码”;
passwordField.backgroundColor = [UIColor whiteColor];
passwordField.keyboardType = UIKeyboardTypeNumberPad;
passwordField.tag = 106;
[passwordField becomeFirstResponder];
[passwordAlert addSubview:passwordField];
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
if ([[systemVersion substringToIndex:1] intValue]<4) {
[passwordAlert setTransform:CGAffineTransformMakeTranslation(0,108)];
}
[passwordAlert show];
[passwordAlert release];
[passwordField release];
}