Today Extension Not Positioned Correctly

梦想的初衷 提交于 2020-01-01 07:20:37

问题


I'm developing a Bitcoin Today Extension and for some reason, the control has an offset. Here's what it currently looks like: http://i.imgur.com/KxeXePS.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: http://i.imgur.com/6vtfNGJ.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.


回答1:


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:




回答2:


Today extensions have margins by default.

Look there for handling with margins: https://developer.apple.com/library/prerelease/ios/documentation/NotificationCenter/Reference/NCWidgetProviding_Protocol/index.html



来源:https://stackoverflow.com/questions/24968280/today-extension-not-positioned-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!