如何在UIAlertView中添加UIWebview?

1 uiwebview uialertview addsubview ios

我尝试使用以下代码:但我只是一个没有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];
Run Code Online (Sandbox Code Playgroud)

Dha*_*iya 9

您必须添加UIWebView为子视图UIViewUIView设定accessoryViewUIAlertView.

试试这种方式

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];
Run Code Online (Sandbox Code Playgroud)