iPhone/iPad通用应用程序方向

San*_*tix 4 iphone orientation ipad

我正在开发通用应用程序的应用程序.现在我想设置两种方式的方向当iPhone上的应用程序启动然后它以纵向模式打开,当应用程序在iPad上启动时,它以横向模式打开.

可能吗 ?

pt2*_*ph8 5

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        return YES;
    } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        return YES;
    }

    return NO;
}
Run Code Online (Sandbox Code Playgroud)