Roymunson Roymunson - 4 months ago 9x
iOS Question

IOS self.view.frame.width equals 0

I am making a custom keyboard. In order to determine the orientation of some buttons I need to find the width of the keyboard. I do this by using:


in my

However, it returns 0.


this can happen in two scenarios 1- you didn't set the size of the self.view (somehow ... if you created that view programmatically..)

2- if you didn't initialize that view at all ...

However if the keyboard width equals the viewcontroller width , you can use this code bekow:

CGFloat width = [UIScreen mainScreen].bounds.size.width;