1

我遇到了设备方向问题。我有一个有一些视图的 iPhone 应用程序,除了一个视图之外,所有视图都不应该旋转。所以我看看里面Info.plist;我选择了两个设备方向,纵向和横向,在视图中我不想旋转,所以我放了这个。

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}

但所有的观点都会旋转。即使有这些线条。如果改成Info.plist不支持人像。它工作正常,只是我想旋转的视图,我把

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

它不起作用。我使用 iOS 6。也尝试过

- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
4

1 回答 1

0

尝试准确指定您希望视图旋转到的方向。例如,如果您只想要肖像,请使用:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

对于旋转到所有视图,您仍然可以使用 YES,尽管这将允许它旋转到并不总是需要的倒置视图。要同时获得横向和正面朝上的纵向,请使用以下命令:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
于 2012-10-01T15:19:10.577 回答