Today Extension height for iPad much larger than specified

前端 未结 3 565
陌清茗
陌清茗 2021-02-11 12:22

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 12:58

    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)
        }
    
    }
    

提交回复
热议问题