iOS today view widgets and margins

One of the toughest things I’ve had to deal with while working on an app has been the today view widget. The widget I’ve been working on is very simple: 2 buttons and a label. Yet, there were a couple of issues I kept running into.

  1. When loading the widget, my buttons will appear and layout. With a button tap, the two buttons change size to what is constrained in the Storyboard. This only happens when the widget is loaded and with the first tap. Subsequent taps don’t affect it again.
  2. The widget, as much as I tried, would not appear as it did in the storyboard. Things weren’t centered properly.

The first item I still haven’t solved. The issue that ended up solving the second item is what I thought was affecting the button layout. Essentially, here is what I had: left button is x points from the left edge of the view, is y points from the right button, and has a width equal to the right button. The right button is the same except it has a constraint to the right edge of the view instead of the left. I had hoped that this would lead to a dynamic button size that would change on various devices and widths. Unfortunately, the small issue with the resizing buttons kept bothering me. If someone can figure this out, let me know.

The second issue was actually fairly easy to figure out. If you look at any of your current widgets, you probably notice two different layouts: ones that are full width, and ones that start indented.

I thought that Apple wanted all widgets indented, but there are even some of Apple’s own widgets that are full width. While it wouldn’t solve the first issue I was having (and gave up on), it did impact why the storyboard, set to the width of the device, wasn’t looking like what my widget was showing.

To solve this, make use of the NCWidgetProviding protocol. There is a method called widgetMarginInsetsForProposedMarginInsets  that you can use to either accept the default margin or set it to a custom value.

By removing the insets, I suddenly had a widget that not only was centered but also was taking up the space in the view as it was in the Storyboard.

If you want to see what I was working on, check out Countr on the App Store.

My thoughts on multitasking on future iPads

Now that we have seen the new iPhones, my thoughts have started to move ahead to the next likely update: iPads. Typically updated on a yearly cycle, the iPad has continued to receive refinements that continue to perfect the device.

Right now, the iPad lineup is strong with the thin and powerful iPad Air and its smaller sibling, the iPad Mini with Retina. If we’re to make any predictions about what is to come, I think we can safely say the next generation of each of those devices with be iterations on the existing models.1

There’s also something new that is rumored to come with the next iPads (or a future iPad Pro): the option to run two apps side by side. Some have wondered how such a feature could operate. Now, I think I have it figured out.2

On the new iPhone 6, due to the larger screen size, Apple introduced something called “Reachability“. By double-pressing (not clicking) the home button, the top half of the screen moves down to within range of the user’s thumb. This is only possible due to the Touch ID sensor, which can respond simply by a finger being on the home button yet not clicking it.

On an iPhone, this makes sense, as the iPhone originally began as a one-handed device. But what about iPads? They have never been designed for one hand.  The next generation of iPads are rumored to include Touch ID.  Obviously, this could allow for increased security on an Apple, as well as the inclusion of Apple Pay. Could Apple also include a new feature for the double-press interface on the iPad? What could it be? Hmm…


  1. Very rarely does Apple introduce a device and not create an upgraded iteration in the same design.  

  2. Because, obviously, I know these things. Okay, no, I don’t. I’m just guessing. But am I close? I’d love to know!