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