Problems with the Widget Today extension

I have a Today widget for my app, however I was informed of a problem with it.

Basically what seems to be happening (I can't test this for myself) is that the widget sometimes just displays "unable to load" and other times it will display with a height of 0.

I can't figure out why this is happening. I have tested it on my device and simulator for several weeks now and have never encountered this problem.

I was wondering if this could be before the update code:

    func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
    // Perform any setup necessary in order to update the view.

    var defaults = NSUserDefaults(suiteName: "group.AffordIt")
    var newCheck = defaults.boolForKey("new")

    if newCheck == true {
        completionHandler(NCUpdateResult.NewData)
    } else {
        completionHandler(NCUpdateResult.NoData)
    }
}

      

'newCheck' is true when something changes in my application that should be displayed in the widgets.

Does anyone know what the possible causes of these problems are?

+3


source to share


3 answers


Failed to load message appears if your extension crashes frequently. You can try re-enabling it by removing and adding the extension again.



+2


source


Are you using your own view controller and xib instead of using storyboard? If so, you may not have set preferredContentSize in your view controller.

try to put the following code in the init function of ur view controller:

    self.preferredContentSize = CGSizeMake(320, 100);

      



I just started extension programming today, so I'm not sure if this is really useful for u or not. Here is the result in my own widget:

enter image description here

+1


source


  • Click Change in modern extensions
  • Remove extension
  • Add extension.
0


source







All Articles