【发布时间】:2012-04-04 18:09:34
【问题描述】:
可能重复:
Best way to programmatically detect iPad/iPhone hardware
例如,我希望我的视图仅在 iPhone 上为纵向,在 iPad 上为横向。
在这种情况下如何检测我是在 iPhone 还是 iPad 上运行?
【问题讨论】:
标签: iphone objective-c ipad orientation
可能重复:
Best way to programmatically detect iPad/iPhone hardware
例如,我希望我的视图仅在 iPhone 上为纵向,在 iPad 上为横向。
在这种情况下如何检测我是在 iPhone 还是 iPad 上运行?
【问题讨论】:
标签: iphone objective-c ipad orientation
写在你的UIViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
else
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
【讨论】: