Iphone: Get current view dimensions or screen dimensions Iphone: Get current view dimensions or screen dimensions objective-c objective-c

Iphone: Get current view dimensions or screen dimensions


Do either of the following lines work for you?

[[UIScreen mainScreen] bounds].size.height[[UIScreen mainScreen] bounds].size.width

I suppose you can subtract the height of the status bar? Maybe i'm not understanding your question


Try this :

UIWindow* window = [UIApplication sharedApplication].keyWindow;NSLog(@"%f",window.frame.size.width);


Useful macros that will give you the correct size based on the device orientation:

#define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height)#define SCREEN_HEIGHT ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width)