Tag: uiscreen

UIScreen主屏幕边界返回错误的大小

所以我用最新版本的XCode创build了一个新项目,并尝试logging我的应用程序的屏幕大小(以确定UI的设备types)。 我从iPhone 5运行以下代码: NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height); 这返回480 ,这是旧的iPhone家庭的屏幕大小。 我在模拟器中尝试过,发生同样的事情。 是否有一些属性,我必须在项目中启用它来识别屏幕大小? 这仅仅发生在5个以上的设备上。 如果我在iPad上运行游戏,它会识别1024屏幕大小。 我知道这个代码在过去有效。 我使用完全相同的方法制作了一个游戏,并且它没有检测屏幕大小的问题,但是这是在XCode 4.x中构build的。 附加信息: 我正在使用自定义视图控制器,我使用下面的代码在App Delegate中创build: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if([Global getDevice] == 1) { //iPhone 5+ self.window.rootViewController = [[FivePlus alloc] initWithNibName:nil bundle:nil]; } else if([Global getDevice] == 2) { //iPhone 4S- self.window.rootViewController […]

.bounds.size在iOS8中变成取向依赖吗?

我在iOS 7和iOS 8中运行以下代码: UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight); NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f", (landscape ? @"Yes" : @"No"), [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); 以下是iOS 8的结果: Currently landscape: No, width: 320.00, height: 568.00 Currently landscape: Yes, width: 568.00, height: 320.00 与iOS 7中的结果相比: […]