我几乎完成了开发我的应用程序。现在我试图让它在 iPhone 4 和 5 中看起来都很好。
我正在尝试获取屏幕的高度,但以下方法不起作用。任何想法?
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
if (screenSize.height == 1136) {
NSLog(@"iphone 5");
}else if(screenSize.height == 960){
NSLog(@"iphone 4 retina");
}else{
NSLog(@"iphone 4 non retina");
}
这是完整的 viewWillAppear 方法:
-(void)viewWillAppear:(BOOL)animated { [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
NSLog(@"%@",NSStringFromCGSize(screenSize));
if (screenSize.height == 568.0f) {
NSLog(@"iphone 5");
}else if(screenSize.height == 480.0f){
NSLog(@"iphone 4 retina");
}else{
NSLog(@"iphone 4 non retina");
}
[firstStepsButton.titleLabel setHidden:YES];
[workingButton.titleLabel setHidden:YES];
[accommodationButton.titleLabel setHidden:YES];
[universityButton.titleLabel setHidden:YES];
[meetMeButton.titleLabel setHidden:YES];
[improveYourselfButton.titleLabel setHidden:YES];
self.navigationController.navigationBarHidden = TRUE;
// self.view.backgroundColor = [UIColor colorWithRed:2/255.0f green:42/255.0f blue:97/255.0f alpha:1.0f];
[super viewWillAppear:animated];
}