iPad横版开发时,宽高是反的

最近刚开始做iPad版应用,但发现横版的时候宽高是反的,很别扭,所以在网上找了一段代码,能够很好的输出宽高

#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)

源自:http://stackoverflow.com/questions/7905432/how-to-get-orientation-dependent-height-and-width-of-the-screen

猜你喜欢

转载自xyxdasnjss.iteye.com/blog/1924611