I'm creating an iOS 8 Custom Keyboard extension primarily using AutoLayout in my XIB. The last step of layout is adding the keyboard keys programmatically. To do this, I need a valid width to properly space keys.
Most StackOverflow posts and references I have read says to perform programmatic layout in viewDidLayoutSubviews
. Most posts say that self.view / self.inputView will not have a valid size in viewDidLoad
so viewDidLayoutSubviews
is the right place to do it.
However, self.inputView.bounds
and self.view.bounds
(and .frame
) give me 0 widths in viewDidLayoutSubviews
in some cases.
Oddly, this only seems to happen in iPhone apps that Auto-Scale/Auto-Zoom for iPhone 6's form factor. Zynga's Words With Friends and my old version of Facebook seems to be one of these.
Can anyone help with this? Why would the inputView
's bounds/frame ever be 0x0 in by the time viewDidLayoutSubviews
gets called? Is there any other better method in which I should add components programmatically?