Preet Preet - 1 year ago 269
Swift Question

Today widget in iOS10 height issue in swift

I am trying to set the height for the today widget in iOS10 but it doesn't worked. It was working before in iOS9.

Answer Source

1) Set the display mode to NCWidgetDisplayModeExpanded in viewDidLoad

override func viewDidLoad() {
    self.extensionContext?.widgetLargestAvailableDisplayMode = NCWidgetDisplayMode.expanded

2) implement given protocal method

[![func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize){
    if (activeDisplayMode == NCWidgetDisplayMode.compact) {
        self.preferredContentSize = maxSize;
    else {
        self.preferredContentSize = CGSize(width: 0, height: 200);

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download