使用的是iOS 6为基数SDK构建的应用程序,并使用自动布局功能制作可以适用于所有类型屏幕的屏幕。你需要Xcode 4.5才能做到这一点。添加一个名为[email protected]
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
//[self ArrangeControllsFor_Protrate];
[self performSelector:@selector(ArrangeControllsFor_Protrate) withObject:Nil afterDelay:0.005f];
return YES;
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
[self performSelector:@selector(ArrangeControllsFor_LandScape) withObject:Nil afterDelay:0.005f];
return YES;
break;
}
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
switch (toInterfaceOrientation){
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
[self performSelector:@selector(ArrangeControllsFor_Protrate) withObject:Nil afterDelay:0.005f];
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
[self performSelector:@selector(ArrangeControllsFor_LandScape) withObject:Nil afterDelay:0.005f];
break;
}
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate{
return YES;
}
-(void)ArrangeControllsFor_Protrate{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self.view setBounds:CGRectMake(0, 0, 320,568)];
[self.view setFrame:CGRectMake(0, 0, 320, 568)];
}
-(void)ArrangeControllsFor_LandScape{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self.view setBounds:CGRectMake(0, 0, 568, 320)];
[self.view setFrame:CGRectMake(0, 0, 568, 320)];
}
- (void)viewWillAppear:(BOOL)animated{
UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if(UIInterfaceOrientationIsPortrait(statusBarOrientation))
{
[self ArrangeControllsFor_Protrate];
}
else
{
[self ArrangeControllsFor_LandScape];
}
}
是的,我向你确认这很简单。 – holex 2013-02-14 09:17:27
可能重复的[如何检测iPhone 5(宽屏设备)?](http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices) – trojanfoe 2013-02-14 09:18:27
可能的重复[如何开发或迁移iPhone 5屏幕分辨率的应用程序?](http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution) – 2013-02-14 09:26:58