如何在 UIAlertView 中添加 UIWebview?

How I can add UIWebview inside a UIAlertView?

我尝试使用以下代码:但我得到的只是一个没有 webview 的警报视图。我应该在哪里更正以获得正确的输出?

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Next Action"message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

        UIWebView *webView = [[UIWebView alloc] init];
        [webView setFrame:CGRectMake(0,0,300,300)];
        [webView loadHTMLString:[@"https://app.acuityscheduling.com/schedule.php?owner=11673736" description] baseURL:nil];
        [alert addSubview:webView];
        [alert show];

您必须将 UIWebView 添加为 UIView 的子视图,并将 UIView 设置为 UIAlertViewaccessoryView

试试这个方法

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Next Action"message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

UIWebView *webView = [[UIWebView alloc] init];
[webView setFrame:CGRectMake(0,0,300,300)];
[webView loadHTMLString:[@"https://app.acuityscheduling.com/schedule.php?owner=11673736" description] baseURL:nil];

UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
[view addSubview:webView];
[alert setValue:view forKey:@"accessoryView"];
[alert show];