1

I am struggling to set the height animated for the Today Extension when a display mode is changed. I have the following code:

- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode
                         withMaximumSize:(CGSize)maxSize
{
    if (activeDisplayMode == NCWidgetDisplayModeCompact) {
        self.preferredContentSize = maxSize;
    }
    else {
        self.preferredContentSize = CGSizeMake(0, 165);
    }
}

It works, however the height of the widget is not animated, it just snaps to the new height. How should I go about doing this?

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
  • I had the same problem when testing in the simulator (no animation, it just jumped), but on the device it animated correctly. Were you testing this in the simulator as well? – stevesw Feb 04 '17 at 03:23

1 Answers1

-1

Override the following method and use the coordinator to animate the update

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
Infinity
  • 3,695
  • 2
  • 27
  • 35
  • Are you saying that he should not set preferredContentSize in widgetActiveDisplayModeDidChange:withMaximumSize: and wait until viewWillTransitionToSize? But will viewWillTransitionToSize even be called if preferredContentSize is not set? – Nicolai Henriksen Oct 15 '16 at 13:49