0

デバイスが iPhone の場合は縦向きにロックし、デバイスが iPad の場合はすべての向きを許可します。

次のコードがありますが、iPhone をポートレート モードでロックしません。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    {
        return NO;

    }
    else
    {
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
        return YES;
    }
    return NO;

}

何が問題ですか?

4

2 に答える 2

0
if you will navigate the view then force orientation will not work but if you will     present your view then it will work very well and it works for me. In my project all screens are in portrait mode only but only one screen is in landscape mode.   
- (IBAction)startButtonClicked:(id)sender {

CTFailure_RemedyGameViewController *remedyGameController = [[CTFailure_RemedyGameViewController alloc]initWithNibName:@"CTFailure_RemedyGameViewController" bundle:nil];
[self presentModalViewController:remedyGameController animated:NO];
[remedyGameController release];
}

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

@end
于 2012-11-05T09:36:45.583 に答える
0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);

    }
    else{
        return YES;
    }

}

これを試して。お役に立てれば。

于 2012-11-05T09:35:05.110 に答える