How to Insert the UITextView into UIAlertview in iOS

南笙酒味 提交于 2019-11-26 17:59:14

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];

the following link has resolved my problem, the link is https://github.com/wimagguc/ios-custom-alertview

the following content has resolved

  1. textview
  2. tableview
  3. ImageView
  4. UIWebView

both functionalities are worked as fine for me

You cannot modify the alert view view hierarchy in iOS7.

You need to either roll your own implementation of an alert view, or use an open source implementation, such as SDCAlertView.

I have tested this myself.

By default UIAlertview content is a textview. How large you are giving the content UIAlertview will definetly present it in a textview.

I think you have given the text in Alertview title. You should have given it in the message.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!