C#/Xamarin Maui
(Xamarin.iOS) WebView 에 html 로 Image 표시하기
kjun.kr
2019. 4. 2. 20:02
728x90
WebView 에 Html 소스 코드를 이용 아래처럼 이미지를 넣었는데
string html = $@"
<html>
<body bgcolor='black'>
<div style='width: 300px; height: 160px; overflow: hidden; position: relative; align-items:center;justify-content:center;'>
<img src='{이미지경로}' style='position: absolute; top:0px; left:-40px; width:380px; height: 180px;'/>
</div>
</body>
</html>";
this.localWebView.Source = new HtmlWebViewSource() { Html = html };
아래 처럼 물음표가 떴다.
안드로이드에서는 아무 이상없이 표시 되었던 항목이 표시가 안되었다.
이를 해결하긴 위해서는 Info.plist 에 아래 항목을 추가해야한다.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads </key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
위항목을 추가하니 아래처럼 이미지가 제대로 표시가 되었다.
728x90