Today Widget Extension Height - iOS10

The height of the widget in iOS 10 is exactly 110 in compact mode. It can be set to whatever height you want in expanded mode, but in compact mode it will always be 110 and that can't be overwritten.


Solution is setting the preferredContentSize at viewDidLoad method.

Here is the example:

Swift 3 and later

override func viewDidLoad() {

    super.viewDidLoad()
    
    self.preferredContentSize = CGSize(width:self.view.frame.size.width, height:210)
    
    if #available(iOSApplicationExtension 10.0, *) {
        self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
    }
}


 @available(iOS 10.0, *)
    @available(iOSApplicationExtension 10.0, *)
    func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
        if activeDisplayMode == .expanded {
            self.preferredContentSize = CGSize(width: self.view.frame.size.width, height: CGFloat(3)*self.tableView.rowHeight)
        }else if activeDisplayMode == .compact{
            self.preferredContentSize = CGSize(width: maxSize.width, height: 110)
        }
    }

Warning

You should use your specific height for your case. 110 is valid in my scenario.

Hope this will fix your issue.

Best