到現在我一直在使用if和else語句來定義顯示在iPhone或iPad,例如像物體的大小:自動調整到iOS設備分辨率
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown){
//For Portrait on iPhone
[self.navBar setFrame:CGRectMake(0.0 , 0.0, 320.0f, 44.0)];
} else if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
//For Landscape on iPhone
[self.navBar setFrame:CGRectMake(0.0 , 0.0, 480.0f, 44.0)];
}
} else {
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown){
//For Portrait on iPad
[self.navBar setFrame:CGRectMake(0.0 , 0.0, 768.0f, 44.0)];
} else if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
//For Landscape on iPad
[self.navBar setFrame:CGRectMake(0.0 , 0.0, 1024.0f, 44.0)];
}
}
但現在我想改變它以使其更具動感。我正在嘗試使用以下內容,但根本沒有運氣。
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
任何人都可以請幫助我如何實施這兩個在一起?看來,我混淆他們的方式是問題所在。如果有人能給我一個模板,甚至暗示我會非常感激。
非常感謝
爲什麼你會在一幀使用比例尺?這沒有任何意義,因爲幀值總是在點,而不是像素... – 2012-02-17 17:15:27