1

I am currently trying to develop my own iOS-App Extension for the Notification-Center but there is a problem with the width. I can not change my widget to be full width like the Calender-Extension on the screenshot. There is always some space to the left that cuts of my Viewcontroller content. (See the Number Widget at the second Screenshot) It seems this is the default behaviour, but there must be a way around this. Any Ideas how to solve this Issue ?

enter image description here

enter image description here

Sebastian Boldt
  • 5,283
  • 9
  • 52
  • 64
  • I am trying to post a notification from my Share Extension to its containing app. Is that possible? What you are doing is also interesting. Is there a way to create an app extension using Xcode? – daniel Nov 04 '22 at 01:55

2 Answers2

4

You have to do this:

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

Taken from Today Extension Not Positioned Correctly

Community
  • 1
  • 1
estemendoza
  • 3,023
  • 5
  • 31
  • 51
1

In your main extension view controller, override - (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets and return whatever UIEdgeInsets your extension needs. If you want 0 padding on all sides, simply return UIEdgeInsetsZero.