0
美好的一天!可可webview iframe(物鏡c)
我有一個HTML頁面與iframe src ....在那裏。我需要將此幀的所有HTML內容都轉換爲NSString。
你可以請建議最好的方式來做到這一點,而不必重定向到web的src?
謝謝。
美好的一天!可可webview iframe(物鏡c)
我有一個HTML頁面與iframe src ....在那裏。我需要將此幀的所有HTML內容都轉換爲NSString。
你可以請建議最好的方式來做到這一點,而不必重定向到web的src?
謝謝。
您可以在NSAttributedString中輸入HTML文本並從中提取字符串。
NSAttributedString * attrString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil];
NSString *finalString = [attrString string];
沒有iframe html源代碼,它由WebView動態加載。 –
webView有一個屬性mainFrameDocument。它給你DOMDocument。和Javascript文檔一樣。 https://developer.apple.com/reference/webkit/webview/1408470-mainframe?language=objc。 – voltae
大型機不包含iFrame的html。 –