iOS與HTML互動問題

來源:互聯網
上載者:User

標籤:標籤   width   替換   scale   mini   字元   ini   break   view   

一.

載入後台傳過來的HTML標籤,文字都能正常顯示但是圖片顯示不了。找問題找了很久沒有發現那個地方寫錯,也問了別人都不知道,後來問了Android才知道,後台傳過來的HTML標籤,有些是轉義過的。移動端這邊識別不了。才造成了圖片不顯示。使用NSString替換字串的方法把轉衣服替換了。就OK。

        NSString * htmlString = [self.htmlString stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\""];

 

二.

圖片文字正常顯示以後,圖片的樣式和和大小顯示的又不正確,問了下知道是後台傳過來的只是body,需要自己拼接頭部。問了公司的H5.

 

NSString *header =@"<head><meta name=\"viewport\" content=\"initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no\"><style>img{max-width: 100%; width:auto; height:auto;}</style><style>*{max-width:100%;max-height:100%}</style></head>";

        

        self.htmlString = [NSString stringWithFormat:@"<html>%@<body><p style=\"word-break:break-all\">%@</p></body></html>",header,self.model.content];

 

PS:如果用到其他標籤請看這篇文章http://blog.csdn.net/huang100qi/article/details/42596799

iOS與HTML互動問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.