Today Extension height for iPad much larger than specified

前端 未结 3 1134
花落未央
花落未央 2021-02-11 12:38

My Today extension needs to have a dynamic height based on the contents the widget is displaying. I was able to achieve this by adding a constraint on my bottom-most element: bo

3条回答
  •  旧巷少年郎
    2021-02-11 13:20

    I had to hardcode the value of the widget on the viewDidLoad delegate method in order to fix this:

    import UIKit
    import NotificationCenter
    
    class TodayViewController: UIViewController, NCWidgetProviding {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            self.preferredContentSize = CGSize(width: 0, height: 320)
        }
    
    }
    

提交回复
热议问题