Swift how to design UIWebView Auto resize full screen in Story Board

余生长醉 提交于 2019-12-04 05:39:39

问题


I designed a UIWebView with 320x500 in StoryBoard. But when run in Iphone 6 Plus Simulator, i want to this webview full screen or scale with the screen of device. How to make it in storyboard?

I wrote code in ViewDidLoad but not working.

override func viewDidLoad() {
        super.viewDidLoad()
        self.detailWebView.frame = self.view.frame;
        println("H:\(self.view.frame.height), W:\(self.view.frame.width)")
        self.configureView()
    }

Seem to be self.view.frame height and width that true, but size of this webview stills 320X500


回答1:


In ViewDidLoad and when you use autolayout, the frame is not yet calculated. So, place your code in viewDidLayoutSubviews or in viewDidAppear, and that should fix the bug.

You can also fix that, only by adding constraints in your interface builder (do not forget to remove your code in viewDidLoad) :



来源:https://stackoverflow.com/questions/28043530/swift-how-to-design-uiwebview-auto-resize-full-screen-in-story-board

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!