iPhone - Auto resizing UIWebView content do not fit the frame

后端 未结 8 759
太阳男子
太阳男子 2020-12-23 17:19

I\'m generating an UIWebView into my viewDidLoad method, with a tiny size (let\'s say something like 50x70). And then I put it into a super UIView.

I\'d like to ma

8条回答
  •  醉梦人生
    2020-12-23 17:45

    For Swift 2.2 I have achieved the same with

    //Document file url
    var docUrl = NSURL(string: "https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjjwPSnoKfNAhXFRo8KHf6ACGYQFggbMAA&url=http%3A%2F%2Fwww.snee.com%2Fxml%2Fxslt%2Fsample.doc&usg=AFQjCNGG4FxPqcT8RXiIRHcLTu0yYDErdQ&sig2=ejeAlBgIZG5B6W-tS1VrQA&bvm=bv.124272578,d.c2I&cad=rja")
    
    let req = NSURLRequest(URL: docUrl!)
    webView.delegate = self
    //here is the sole part
    webView.scalesPageToFit = true
    webView.contentMode = .ScaleAspectFit
    webView.loadRequest(req)
    

提交回复
热议问题