4

I'm currently working on an iOS Today Extension and I'm having an issue with the extensions height. I've tried from scratch multiple times and I can't seem to figure out where the extra height is coming from. Where am I going wrong with AutoLayout. Thanks.

Storyboard View:

Storyboard View

Scene View:

Scene View

Size Inspector for View:

Size Inspector

Results:

Simulator

I also tried using the following and it said this:

override func viewDidLoad() {
    super.viewDidLoad()
    self.preferredContentSize = CGSizeMake(0, 100);
}

PreferredContentSize

Edit: Could this be an iOS bug?

I've been beating my head against the desk over this for a while now but I've noticed a repeatable pattern on the simulator as well as a physical device. If I reset contents and settings on the simulator then run the Today Extension on it, it fills the entire space (even though it's not honoring my 100 height constraints), but as soon as I 'stop' running it, the view shrinks to 100 height and there is this extra padding at the bottom. Does anyone else experience this? Is this a bug or is this something that I am causing?

First run, while 'running':

First run, while running

After 'stopping' and subsequent 'runs'

After 'stopping'

Shawn H.
  • 749
  • 1
  • 9
  • 22
  • I've noticed that whenever I make changes, if I Reset Contents and Settings on the simulator the changes appear to work properly. Whenever I try to run the Today Extension again (without resetting), it shrinks the view's height until I Reset Contents and Settings again. – Shawn H. Jan 31 '15 at 17:06
  • Did you ever figure this out? I'm having the exact same issue. Removing and re-adding the extension to the Today screen fixes it until the next time you run or refresh it. – bgolson May 05 '15 at 17:16
  • @bgolson - No, I was never able to figure it out. I chalked it up to a system bug. – Shawn H. May 05 '15 at 23:30
  • Thanks for following up! Finally found the answer and posted below. – bgolson May 06 '15 at 13:39

1 Answers1

5

Finally found the issue! Apple has absurd default margins, especially on the bottom. And the only way to change them is to implement the widgetMarginInsetsForProposedMarginInsets method. Here's the swift code:

func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
    return UIEdgeInsetsZero
}
bgolson
  • 3,460
  • 5
  • 24
  • 41