3
我经历了许多不同的问题,出于某种原因,我仍然无法让我的iPad检测负载方向。无法检测负载方向 - iPad
好像要做到这一点,最好的方法是通过检测statusBarOrientation:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"View Loads");
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft
|| [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
NSLog(@"This is Landscape");
} else {
NSLog(@"This is Portrait");
}
}
但它总是返回“肖像”。我在我的.plist可用的所有4个方向和shouldAutorotateToInterfaceOrientation设置以及:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationPortrait);
} else {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
没有人有任何其他建议吗?提前致谢!
无论设备方向如何,您的应用总是以纵向显示吗? – MusiGenesis 2012-04-05 22:26:06
不,我的应用可以朝着任何方向转动,除了人像颠倒。 – 2012-04-05 23:24:13