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)
您必须添加UIWebView为子视图UIView并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];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1644 次 |
| 最近记录: |