0

I have a third-party keyboard and I want to make the buttons proportional to the width of the keyboard (which changes based on device/orientation).

I pass along the buttons to the function:

func addIndividualButtonConstraints(buttons: [UIButton], mainView: UIView) {
 let buttonWidth = mainView.frame.width / 12
...
}

mainView is equal to the width of my keyboard (set in IB). But mainView.frame.width gives me 320, even if the width of the keyboard is actually 414 (as in iPhone 6s Plus).

It seems that it's just using the dimensions of the keyboard that I've set in IB (which is 320 x 200), and only later at run-time does the keyboard expand to fit the device.

How do I get these run-time dimensions and pass them into my function?

vk2015
  • 1,118
  • 1
  • 12
  • 16
  • 1
    Take a look at this question: http://stackoverflow.com/questions/25451001/getting-keyboard-size-from-userinfo-in-swift – Tamás Sengel Jul 26 '16 at 16:25
  • Thanks for the suggestion - I tried following along, but it didn't seem to work for me - now, none of my constraints seem to be working. Did you mean a specific part of that question? – vk2015 Jul 26 '16 at 20:08

0 Answers0