1

I'm building an iOS 10 widget and I noticed that by default, they're all one standard size calculated by the system.

As a developer, you can use the NCWidgetDisplayMode and choose the expanded option to provide more information inside your widget as it will expand the height of the widget.

Using this option (which I set in viewDidLoad) will also give a "Show More/Show Less" button on the upper right. Choosing the compact option will not put this toggle in the upper right.

This is great and all but if I choose the expanded option in order to have my widget in two optional sizes, it always starts expanded.

How can I have the option to show a compact and expanded widget but start out with the compact option? It always starts out in its expanded size and I do not want this.

Mario A Guzman
  • 3,483
  • 4
  • 27
  • 36
  • Would you like to put your code in viewDidLoad? Cause when I set my extension to expand. It starts with compact size. – ronan Nov 01 '16 at 06:40
  • 1
    Look here: http://stackoverflow.com/a/39203978/3108877 – Rob Nov 01 '16 at 06:43
  • @ronan - I do have my code in 'viewDidLoad.' I set the widget to 'expanded' in viewDidLoad so that I can get the Show More / Show Less option in the widget. You don't get this if you choose 'compact.' The problem is that the widget will also load into view in its expanded view. I want it to start in its compact view. – Mario A Guzman Nov 01 '16 at 18:10
  • @Rroobb - That isn't really helping me. I know that I can implement the widgetActiveDisplayModeDidChange which is great but it doesn't help me with the initial load of the widget. – Mario A Guzman Nov 01 '16 at 18:14
  • I think it always displays in expand mode, because you set it to expand mode before. You can try to uninstall it, and to see what mode it is. In my project, it displays in compact the first time launch it. – ronan Nov 02 '16 at 01:42
  • @ronan - I havent noticed that!!! So, what you're saying is that it remembers the compact/expanded state automatically? Maybe I always had left it expanded. I'll have to double check because I could have sworn that I did uninstall it and then reinstall it only to find it in the expanded mode again. I'll have to try by making it compact and then uninstalling it to reinstall right after and see what state is it in. – Mario A Guzman Nov 02 '16 at 05:06

0 Answers0