iosxcodetoday-extensionios10-today-widget

Getting the height of the Compact Height of the Widget when it's in Expanded Mode


How can I get the Compact Height when the widget is displayed in Expanded Mode? I would set the size of the Expanded mode of the widget double the size of the Compact Mode. Compact Size is Fixed for iPad and iPhones but it's different when it comes to iPad Pro.

Removing the Widget keeping the app in Expanded mode and When later adding the widget would appear on the screen with Expanded mode. OS maintains the state. So now I would not get the Compact size Since it's directly being loaded on the Expanded mode.

I don't wanna have static value for iPad Pro and For the other devices separately. This should be done generic, So in future this won't get affected if apple changes the FIXED compact mode size.


Solution

  • I located the solution for this.

    CGSize siz = [self.extensionContext widgetMaximumSizeForDisplayMode:NCWidgetDisplayModeCompact];
    

    This would give me the Compact Size.