【发布时间】:2011-07-11 13:09:44
【问题描述】:
在得到miamk的支持后,我离实现我想要的又近了一步。但是现在有以下问题:
我有一个 iPad 应用程序,可以在所有四种视图模式(纵向上/下和横向左/右)下使用。但在某个时刻,我有一个视图,我只想在 landscape 模式下看到。所以我在 UIViewController 中执行以下操作,这将触发查看纯横向视图的操作:
- (void) showProperty:(Property *) property {
if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft || [self interfaceOrientation] == UIInterfaceOrientationLandscapeRight) {
PropertyViewController *propertyView = [[PropertyViewController alloc] initWithNibName:@"PropertyViewController" bundle:[NSBundle mainBundle]];
propertyView.property = property;
[self.navigationController pushViewController:propertyView animated:YES];
[propertyView release];
propertyView = nil;
}
else {
RotateDeviceViewController *rotateView = [[RotateDeviceViewController alloc] initWithNibName:@"TabRotate" bundle: [NSBundle mainBundle]];
rotateView.property = property;
[self.navigationController pushViewController:rotateView animated:YES];
[rotateView release];
rotateView = nil;
}
}
这可以正常工作,因此当 iPad 处于横向模式时会显示所需的屏幕 (PropertyViewController),如果不是,它会显示 RotateDeviceViewController,它会向用户显示他/她应该正确旋转设备的消息查看屏幕。
这样就行了!
那么问题就出现在这个RotateDeviceViewController中了。我有以下内容:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
[self showProperty];
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
- (void) showProperty {
PropertyViewController *propertyView = [[PropertyViewController alloc] initWithNibName:@"PropertyViewController" bundle:[NSBundle mainBundle]];
propertyView.property = property;
[self.navigationController pushViewController:propertyView animated:YES];
[propertyView release];
}
因此,当我将设备(查看 RotateDeviceViewController 时)旋转到横向模式时,我会向用户显示 PropertyViewController。这行得通...但是当 PropertyViewController 出现时,它显示我的布局旋转了 90 度。所以基本上它以 portrait 模式显示内容,而不是使用 landscape 模式(这实际上是您拿着设备的方式)..
我希望这是有道理的,有人可以告诉我是什么原因造成的。
【问题讨论】:
-
你们如何交换意见?这可能是相关的:stackoverflow.com/questions/835989/…
标签: objective-c xcode ipad orientation landscape