简体   繁体   中英

App displaying in landscape when on iPhone mode on iPad

When my app launches on the iPhone, it displays in portrait, as it should. When it launches on the iPad in iPhone mode, it displays in landscape, if rotated that way. This is the code I have:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate {
    return NO;
}

For iOS 6, have you try :

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

在您的项目info.plist文件中,从受支持的方向列表中删除横向标志。

In Xcode select one of your target then under summary tab make sure you have selected only UIpotrait orientation and rest all of them are unslected, then choose info tab and see that under "supported interface orientations" row it should have only UIpotrait orientation .Now open your delegate file and for ios5 this method works

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }

but this method is deprecated for iOS6 to override it for iOS6

-(BOOL)shouldAutorotate {

return YES;

}

-(NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskPortrait;

} - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

return UIInterfaceOrientationMaskPortrait;

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

return UIInterfaceOrientationPortrait;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM