ios10: viewDidLoad frame width/height not initialized correctly

前端 未结 7 966
闹比i
闹比i 2020-12-07 20:23

Since upgrading to XCode8 GM and ios10, all of my views created via Interface Builder are not being initialized correctly until much much later than expected. This means in

7条回答
  •  情话喂你
    2020-12-07 21:10

    We created a radar (28342777 (marked as duplicate for 28221021 but Open)) for the similar problem and the reply that we got was as below:

    "Thank you for reporting the issue. Could we get more information about the profile image view? In Xcode 8, a fully constraint, non-misplaced view no longer saves out a frame to minimize diffs and support automatically update frames in IB. At runtime, these views get decoded with a placeholder size of 1000x1000, but are resolved after first layout. Could the image be assigned before initial layout, and would assigning the image to the image view after first layout address this case? Please send a sample to help us further analyze. thanks!"

    At present we have provided them the sample project. My observations:

    • The problem that we had used to happen for XIBs that are converted from Xcode 7.x to Xcode 8.x
    • If we intentionally break the constraint in XIB then viewDidLoad will get expected height and width and not 1000x1000.
    • For us it was a UIImageView on which we were apply some layering for making it circular and using masksToBounds. If we set masksToBounds = NO then we everything was working fine.

    Though Apple claims that it is going to be a standard from Xcode 8 that views will be set to 1000x1000, the behavior doesn't seem to be consistent.

    Hope this helps.

提交回复
热议问题