2015-09-25 59 views
1

我試着用下面的代碼:但我只是簡單的沒有webview的警報視圖。我應該在哪裏糾正以獲得正確的輸出?如何在UIAlertView中添加UIWebview?

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

看到此鏈接可能是幫助你http://stackoverflow.com/questions/20737426/how-to-insert-the-uitextview-into-uialertview-in-ios –

回答

6

您必須添加UIWebViewUIView子視圖和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]; 
+0

謝謝Dharmesh ..它的工作原理:-) – Nimmy

+0

@Nimmy歡迎任何時間。 –

相關問題