you can subclass UIAlertView class to have a textField (or multiple textfields)
here is how your custom class will look like: (AlertPrompt.h)
@interface AlertPrompt : UIAlertView
{
UITextField *emailTextField;
UITextField *nameTextField;
}
@property (nonatomic, retain) UITextField *emailTextField;
@property (nonatomic, retain) UITextField *nameTextField;
- (id)initWithTitle:(NSString *)title delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okButtonTitle;
@end
AlertPrompt.m
#import "AlertPrompt.h"
@implementation AlertPrompt
@synthesize emailTextField, nameTextField;
- (id)initWithTitle:(NSString *)title delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okayButtonTitle
{
if (self = [super initWithTitle:title message:@" \n\n\n" delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
{
self.frame = CGRectMake(0, 0, 300, 400);
UITextField *nameTF = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
UITextField *emailTF = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 80, 260.0, 25.0)];
[nameTF setBackgroundColor:[UIColor whiteColor]];
[nameTF setAutocorrectionType:UITextAutocorrectionTypeNo];
[nameTF setPlaceholder:@"name"];
[emailTF setBackgroundColor:[UIColor whiteColor]];
[emailTF setAutocorrectionType:UITextAutocorrectionTypeNo];
[emailTF setPlaceholder:@"email"];
[self addSubview:nameTF];
[self addSubview:emailTF];
self.nameTextField = nameTF;
self.emailTextField = emailTF;
if (delegate) {
self.emailTextField.delegate = delegate;
self.nameTextField.delegate = delegate;
}
[nameTF release];
[emailTF release];
}
return self;
}
- (void)show
{
[nameTextField becomeFirstResponder];
[super show];
}
- (void)dealloc
{
[nameTextField release];
[emailTextField release];
[super dealloc];
}
@end
you'll notice that am passing @" \n\n\n" as parameter in the init method so that makes space for the textFields I want to display.. so you'll have to modify the message param depending on the number of textfields you want to display in the prompt.
Hope this helps