How to Insert the UITextView into UIAlertview in iOS

This should work. Give it a shot. But it’s a hack and might not be appreciated by Apple.

UIAlertView *testAlert = [[UIAlertView alloc] initWithTitle:title
                                                    message:@""
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"Done", nil];
UITextView *textView = [UITextView new];
if (SYSTEM_VERSION_LESS_THAN(@"7.0"))//For Backward compatibility 
{
    [testAlert addSubview: textView];
}
else
{
    [testAlert setValue: textView forKey:@"accessoryView"];
}
[testAlert show];

Leave a Comment