如何获得iPhone 6或6 Plus的确切屏幕尺寸

How to get the exact screensize of an iPhone 6 or 6 Plus

本文关键字:屏幕 Plus 何获得 iPhone      更新时间:2023-10-16

我正在使用cocoas2d-x V3.0。我试过了

Size    screenSize = CCDirector::getInstance()->getWinSizeInPixels();

但它返回iPhone 5的大小(640 * 1136),而我正在iPhone 6或iPhone 6plus模拟器上进行测试。

您需要获取 cocos2d-x v3.3,因为以前版本的 cocos2d-x 无法获得 iPhone 6 和 iPhone 6 plus 的正确屏幕分辨率,因为它们仍然认为比例因子为 2 而不是 3,因此返回 iPhone 5 分辨率。

这个问题已经讨论过 这个链接: https://github.com/cocos2d/cocos2d-x/issues/8545

You need to add Launch images for Iphone 6 & 6+ , only then 
it will show you its real screen size.
Go to your Xcode -> Select Target -> Select General -> 
select Launch Image Source under App Icons & Launch Images . 
Now you can add there your launch images for iphone 6 & plus
which could be 1334*750 & 2208*1242 For landScape mode.
Now you can have your device screenSize with following code .
Size WinSize= Director::getInstance()->getWinSize(); 
i have faced same thing in my project & this way i solved it.
i am using Xcode 6 & cocos2d-x 3.2 
I hope this helps.