view.traitCollection.horizontalSizeClass returning undefined (0) in viewDidLoad

前端 未结 5 580
忘掉有多难
忘掉有多难 2021-02-12 13:19

I\'m using a UITextView inside a UIPageViewController, and I want to determine the font size based on the size class of the device.

The first slide of the page view is l

5条回答
  •  不思量自难忘°
    2021-02-12 13:48

    You will be better off moving that code to the viewWillAppear method, as in the viewDidLoad the ViewController's view has not been added to the hierarchy yet, and you might get an empty trait collection.

提交回复
热议问题