1

I am working on an application which provides a new Today Extension/Widget for the Notification Center, as this feature has been added with iOS 8.

However, I need the extension to choose between a couple different view controllers, all set up in Storyboard, based on the values of one simple variable. So if the user makes changes in the main application, this variable will have a different value and therefore the Today Extension is supposed to load a different initial view controller.

I have read similar questions and their solutions, so I tried to setup a dummy view controller as the initial view controller on the extension storyboard, create multiple modal segues pointing to the other view controllers, gave all of them an identifier name, disabled animation on the segues and implemented a custom class for the dummy view controller. This class then calls performSegueWithIdentifier: sender:nil in viewDidAppear:. However, this seems to be not working with the today extension, in only shows "Unable to load" when I test it in simulator.

Edit: Ok, I was doing something wrong, it actually does work. But every time notification center is opened, the content of the displayed view controllers disappears and reappears in a matter of milliseconds, because the dummy view controller is loaded again. Additionally the extensions height is not changing when presenting one of the other view controllers.

What could I do to achieve the desired behavior of the today extension?

Andrew
  • 15,357
  • 6
  • 66
  • 101
lerei
  • 133
  • 5

1 Answers1

0

Could you use a TableViewController, and put the different logic into TableCell instead of ViewController. It's easy to select different TableCell against your variable in tableView(tableView:, cellForRowAtIndexPath:).

Quanlong
  • 24,028
  • 16
  • 69
  • 79