There is no size of the a view controller. Its the size of the view or the window.
you can use the .frame
or .bounds
method to get it.
Also you can easily print the rect using,
NSLog("Frame: %@", NSStringFromCGRect(self.view.frame));
NSLog("Frame: %@", NSStringFromCGRect(self.view.window.frame));
You can also use the [UIScreen mainScreen].bounds
to get the size of the full screen. You will always get that 20 pixel offset in x or y direction, for the status bar, depending on your orientation.
Whatever happens, the frame returns the height and width, assuming the device is in portrait mode, with the home button down. So when the device is in landscape mode, the status bar is on the right side, and the width is 20 pixel less to make room for the status bar.
Edited: After iOS 8
Now you get the width and height correctly in portrait and landscape orientation. i.e. as it looks -- in landscape width=portrait height. When I use in my code,
CGRect frame = [[UIScreen mainScreen] applicationFrame];
CGSize size = frame.size;
if (![UIUtil isAfterIOS8]){
size.width = frame.size.height;
size.height = frame.size.width;
}
/* UIUtil.m */
+ (BOOL) isAfterIOS8 {
return [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0;
}