ios - 在 UIWebView 中以正确的格式显示文档 (iOS)

标签 ios swift uiwebview doc

我正在 UIWebView 中打开一个 word 文档文件。

它工作得很好,但问题是当我打开那个 doc 文件时,它没有像在 word 中那样以正确的格式显示。

在 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

最佳答案

鉴于您已缩放页面以适应,看起来您可能没有正确设置约束。

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

您可以在 Storyboard和代码中创建约束。

关于ios - 在 UIWebView 中以正确的格式显示文档 (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30374509/

相关文章:

ios - UItableviewCell 的背景颜色不起作用

ios - ITMS-90809 : Deprecated API Usage -- Apple will stop accepting submissions of apps that use UIWebView APIs

iphone - 在 iOS 上做阴影的最快方法是什么?

ios - 挑战 : Best way to check if model object array contains properties of model in Objective-C

ios - 在 -shouldAutorotateToInterfaceOrientation : 中预测 UI 元素框架

swift - 服务器端 Swift : Navbar Toggle not working in Vapor 4 Leaf + Bootstrap

swift/IOS/核心数据 : How would I define a var as an enum type in an auto-generated CoreData class?

swift - Swift 中的枚举模式匹配

ios - iPhone 6 UIWebView 选择下拉问题

javascript - 在函数调用之间保留变量值javascript