widgetios8ios8-extension

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?


Solution

  • 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:

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