在UIWebView中以适当的格式显示文档(iOS)

时间:2015-05-21 12:58:40

标签: ios swift uiwebview doc

我在UIWebView打开word文档文件。

它运作完美,但问题是,当我打开该doc文件时,它不会以正确的格式显示,如文字。

在UIWebView中:

This is the problem all text are display in center

代码:

let url = NSURL(string: self.docUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
    let request = NSURLRequest(URL: url!)
    webView.loadRequest(request)
    webView.delegate = self
    webView.scalesPageToFit = true // I have also try by removing this statement
    webView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight

1 个答案:

答案 0 :(得分:0)

鉴于您有适合的比例页面,看起来您可能没有正确设置约束。

您需要在UIWebView及其父级之间创建约束,以确保webView接管整个屏幕。

您可以在故事板和代码中创建约束。