Wednesday, July 20, 2011

Add UITextFiled on UIAlertView

//Open a alert with text field, OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Send Email"
                                                message:@" "
                                               delegate:self
                                      cancelButtonTitle:@"Cancel"
                                      otherButtonTitles:@"Send"nil];

CGRect frame = CGRectMake(144525523);
if(!emailField) {
    emailField = [[UITextField alloc] initWithFrame:frame];
    emailField.borderStyle = UITextBorderStyleBezel;
    emailField.textColor = [UIColor blackColor];
    emailField.textAlignment = UITextAlignmentCenter;
    emailField.font = [UIFont systemFontOfSize:14.0];
    emailField.placeholder = @"";

    emailField.backgroundColor = [UIColor whiteColor];
    emailField.autocorrectionType = UITextAutocorrectionTypeNo;
    //no auto correction support

    emailField.keyboardType = UIKeyboardTypeEmailAddress; // use the default type input method (entire keyboard)
    emailField.returnKeyType = UIReturnKeyDone;
    emailField.delegate = self;
    emailField.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
}
[alert addSubview:emailField];
[alert show];
[alert release];

No comments: