Alert with textfield

iPhone SDK Tips & Tricks

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:@"username\npassword\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];

usernameTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 40.0, 260.0, 25.0)];
[usernameTextField setBackgroundColor: [UIColor whiteColor]];
usernameTextField.placeholder = @"Username";
[usernameTextField becomeFirstResponder];
[alert addSubview:usernameTextField];

passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 70.0, 260.0, 25.0)];
passwordTextField.placeholder = @"Password";
[passwordTextField setBackgroundColor: [UIColor whiteColor]];
[alert addSubview:passwordTextField];