-1

重複の可能性:
iPad/iPhoneハードウェアをプログラムで検出するための最良の方法

たとえば、iPhoneではビューを縦向きにし、iPadでは横向きにします。

この状況でiPhoneまたはiPadで実行されているかどうかを検出するにはどうすればよいですか?

4

1 に答える 1

5

あなたの中にこれを書いてくださいUIViewController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    else
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
于 2012-04-04T18:15:19.787 に答える