Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 Today widget alignment issue

Here is my storyboard

enter image description here

I'm using autolayout, and NOT using size classes.

When I ran it on iPhone 5s, it works fine.(both portrait and landscape) enter image description here

But when I ran it on iPhone 6 plus (portrait), it's not aligning properly. enter image description here

on iPhone 6 plus (landscape), it's worse. enter image description here

I know I can use -widgetMarginInsetsForProposedMarginInsets: to set the margin, but in that case I will need to customize the margin for every device. That would be horrible :(

So is there a way to align the subview to the title less painfully?

like image 581
Keoros Avatar asked Sep 24 '14 19:09

Keoros


2 Answers

Setting the edge insets to zero should fix the problem:

- (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets
{
    return UIEdgeInsetsZero;
}
like image 143
Stephen Avatar answered Oct 19 '22 08:10

Stephen


Looks like you have to set it manually. You can do this by creating a constraint, then specifying an IBOutlet to it, and setting the constant depending on the device/orientation.

For reference, here are the margins I found you needed:

  • 5S - 1 (2px)
  • 6 - 1 (2px)
  • 6 plus portrait - 5 (15px)
  • 6 plus landscape - 34 (102px)

You can find which one you need from the size of the extension view, which is 414 pt for a portrait iPhone 6.

like image 33
Simon Fry Avatar answered Oct 19 '22 09:10

Simon Fry