有時候App畫面需要套用Web內容,你就會發現很神奇的地方,就是Web開發者說已經調整好寬度100%,可是在我們App中顯示就是有問題,像是貓咪的臉會被截掉⋯⋯
那到底是誰的問題呢?基本上我是認為Web寫好直接套用就要呈現期望的樣子,App這邊不需要特別設定什麼。
不過呢⋯⋯也許App元件本身有問題,此時就要找出替代方案,總是有前人遇過類似的問題,google就對了!
果真嘗試去改HTML檔,將CSS設定max-width:100%,而height:auto,就呈現我們要的結果啦~
/** Theme: Adjust Image Width in HTML IDE: Xcode 8 Language: Objective C Date: 106/01/18 Author: HappyMan Blog: https://cg2010studio.wordpress.com/ */ NSString *strTemplateHTML = [NSString stringWithFormat:@"<html><head> <style>img{max-width:100%%;height:auto !important;width:auto !important;};</style> </head><body style='margin:0; padding:0;'>%@</body></html>", @"insert your html content here"]; [webView loadHTMLString:strTemplateHTML baseURL:nil];
另外想說AirDrop超好用,在別台手機iPhone截圖要傳到我的筆電Macbook Air,到相簿選取好影像後分享,內建的功能就會自動找出附近的裝置,確認傳送給對方,對方看到後按接收,馬上就取得原始影像!
隨意留個言吧:)~