KD. KD. - 1 year ago 117
Swift Question

How to use auto layout on IOS8 Keyboard extension

Trying to make auto layout work with the keyboard extension. Initially i thought i will make the buttons programmatically but then i realized its better to do it with a xib because of my requirement and multiple screen sizes.

Please see the screenshot below on the current configuration i have made.
Button 2:
enter image description here

Button 1 and issue on the app:
enter image description here

All the constraints configuration looks like this:
enter image description here

All i am trying to do here is to make sure the button fills up the screen width. They can expand in width to match screen sizes and orientations. Somehow i feel that its not able to understand the device width. Do i need to specify something for that?


Answer Source

Make sure to set the UIView's dimensions on viewDidLoad so that it looks like something like this:

self.mainView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

I had the same problem and this did the trick for me. Your constraints are just fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download