我尝试使用以下代码:但我得到的只是一个没有 webview 的警报 View 。我应该在哪里更正以获得正确的输出?
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
的 subview 和 UIView
设为accessoryView
的 UIAlertView
.
试试这个方法
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];
关于ios - 如何在 UIAlertView 中添加 UIWebview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32779280/