【发布时间】:2012-09-24 10:53:56
【问题描述】:
我想用 iPhone 5 的分辨率测试我的应用程序,所以我正在使用模拟器。我的应用在支持的设备方向中有纵向和 2 个横向方向,并且允许旋转的视图控制器将 shouldAutorotateToInterfaceOrientation 设置为 YES。然而,当我在模拟器中旋转设备时,它不会像在设备上那样旋转。现在我只是在使用标准的 iPhone 4 模拟器。
编辑:这是我设置 VC 的代码。
UIViewController *vc = [[UIViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
[self.window addSubview:self.navigationController.view];
self.loadingWood = [[UIImageView alloc] init];
[vc.view addSubview:self.loadingWood];
然后不久:
self.timeline = [[JTimelineViewController alloc] init];
[self.navigationController setViewControllers:[NSArray arrayWithObject:self.timeline]];
这对于应用启动时的视觉效果是必要的。
编辑 2:
我现在有这个工作。我现在面临的问题是,尽管我的一个 viewControllers 说明了这一点,但它仍然会在 iPhone 模拟器上进行任何旋转时旋转:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
编辑 3:我的手机运行的是 iOS5。模拟器运行iOS6。这是一个可能的原因。删除横向左和横向右作为支持的方向意味着根本没有模拟器旋转,但我的 iOS5 iPhone 4 继续正常旋转。
【问题讨论】:
-
它在 iPhone 4 模拟器上旋转吗?
-
没有。它在我拥有的实际 iPhone 4 上旋转。
-
哇,有趣...让我试试这个!我现在真的很好奇......:D
-
很好的问题。 +1!尽管如此,我刚刚在 Xcode 中创建了一个新项目并在 iPhone 模拟器(4 和 5)中运行了代码,并且旋转工作正常。没有代码,调试起来可能有点棘手。
-
你能不能试着用 [self.navigationController pushViewcontroller:self.timeline animated:NO(or YES if you want animation)] 替换 setViewControllers: 行;
标签: iphone objective-c ios xcode simulator