- (IBAction)buttonAction:(UIButton *)sender {
//自己定义一个UITextField添加上去,后来发现ios5自带了此功能
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"请输入地址" message:@" " delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
UITextField * txt = [[UITextField alloc] init];
txt.placeholder = @"请输入地址";
txt.backgroundColor = [UIColor whiteColor];
txt.frame = CGRectMake(alert.center.x+65,alert.center.y+48, 150,23);
alert.delegate = self;
[alert addSubview:txt];
[alert show];
}
获取AlertView中文本框
UITextField *textField = [alertView textFieldAtIndex:0];