Search code examples
widgetios8ios-app-extension

Today Extension Not Positioned Correctly


I'm developing a Bitcoin Today Extension and for some reason, the control has an offset. Here's what it currently looks like: https://i.sstatic.net/08WV2.png

As you can see, the button is barely on the screen, and the label isn't on the left side.

My storyboard looks like: https://i.sstatic.net/u4GC6.png

I've tried settings multiple kinds of constraints, and none of them seem to fix the issue. I'm not sure what other information I can add, but if you have any questions about the project, I can answer them.


Solution

  • To disable the margin you have to use the function widgetMarginInsetsForProposedMarginInsets.

    Place this in your code (Swift):

    func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
            return UIEdgeInsetsMake(0, 0, 0, 0)
    }
    

    Good luck!!

    Reference: https://developer.apple.com/library/prerelease/ios/documentation/NotificationCenter/Reference/NCWidgetProviding_Protocol/index.html#//apple_ref/occ/intfm/NCWidgetProviding/widgetMarginInsetsForProposedMarginInsets: