Does WatchKit support html? is there is controller like UIWebview?

前端 未结 4 739
温柔的废话
温柔的废话 2021-01-03 02:55

Does WatchKit support html? is there is controller like UIWebview ?.

My client want to show webpage in a Apple Watch. is this possible ?

4条回答
  •  北海茫月
    2021-01-03 03:22

    There is no webView in watchKit ,But i managed to convert HTML to formatted String

    func convertHTMLToFormattedText ( htmlText : String , myLabel : WKInterfaceLabel) {
    
        let attributeText: NSAttributedString?
    
        if let htmlData = htmlText.dataUsingEncoding(NSUnicodeStringEncoding) {
    
            do {
    
                attributeText  =  try   NSAttributedString(data: htmlData , options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
                myLabel.setAttributedText(attributeText)
    
            }catch let e as NSError {
                print("Couldn't translate \(htmlText): \(e.localizedDescription) ")
            }
    
    
        }
    }
    

提交回复
热议问题