3

I am working on an Today Extension for Yosemite. I would like to show a SettingsViewController instead of going into edit mode. If I "presentViewControllerInWidget" on "widgetDidBeginEditing" it gets some weird glitches and the view controller is hiding and showing all the time.

Did anyone achieved to show an viewController on info button click or knows a workaround on that glitch?

func widgetDidBeginEditing() {
    self.presentViewControllerInWidget(self.settingsViewController)
}
nohayeye
  • 1,839
  • 2
  • 15
  • 15

2 Answers2

1

This worked for me:

func widgetDidBeginEditing() {

    var delay = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
    dispatch_after(delay, dispatch_get_main_queue()) {
        self.presentViewControllerInWidget(self.settingsViewController)
    }
}
josip04
  • 163
  • 2
  • 11
  • This does indeed work for me as well, but when I press the cancel button, the view collapses entirely (after for a fraction of a second showing the correct content). Using dispatch_after is not a proper solution though :( – Thomas Krajacic Nov 01 '14 at 18:38
  • I had similar problems and tried to subclass NCWidgetSearchViewController instead of NSViewController and that worked correctly. – josip04 Nov 02 '14 at 20:15
  • I just encountered the same issue as @ThomasKrajacic where the view collapses entirely – I solved this by setting changing my view's "Layout" from "Translates Mask Into Constraints" to "Automatic" in Interface Builder. – Josh Aug 29 '20 at 01:56
1

I guess this is a bug that made it into the Yosemite release. Documentation on widgets is very sketchy at best and it seems there are quite a few oddities in the framework.

When adding a symbolic breakpoint to widgetDidBeginEditing I get two hits when clicking the little edit button, and the edit Button becomes "Cancel". It is supposed to say "Done" though. Only after an "Add" action should it say "Cancel" (Just check out Apple's Weather widget)

Important to say: I am not using the template with the NCWidgetListViewController but my own list implementation.

If anyone finds a proper solution to this problem I'd be very happy!

Thomas Krajacic
  • 2,088
  • 19
  • 24