Xcode 9 and 9.1 selected device on the storyboard affects the width of the view on the deployment device

I noticed something very strange with Xcode 9. When I’m on the main storyboard and I change the device selected to view the view controllers in the appropriate format, I noticed that the width of my table view in viewDidLoad is incorrect if the selected device in the storyboard is different from the one on which I deploy the device. I did tests, and it seems that the layout of the selected device on the storyboard is done.

Has anyone already experienced this problem?

This issue is also present in beta version 9.1 of Xcode.

+4
source share
1 answer

, UITableViewCell. .

layoutSubviews() layoutIfNeeded() , . :

override func layoutSubviews() {
    super.layoutSubviews()

    print("cardView frame: \(cardView.frame)") // Storyboard size
    cardView.layoutIfNeeded()
    print("cardView frame: \(cardView.frame)") // Runtime device size
    // Perform your layout here. 
}

, !

0

Source: https://habr.com/ru/post/1686727/


All Articles