【发布时间】:2011-11-07 11:16:58
【问题描述】:
我还有一个方向问题。但这一个非常棘手。 我的 RootViewController 是一个普通的 NavigationController。
self.window.rootViewController = _naviController;
里面有另一个ViewController,我们称之为VC1。 VC1 有一些按钮和标签。它就像一个文件夹概览。
如果我按下一个按钮,我会来到下一个 ViewController,其中包含 3 个 ViewController(页面)和另一组按钮(比如在文件夹中查看里面的图片/缩略图):
Archiv *archiv = [[Archiv alloc] init];
[self.navigationController pushViewController:archiv animated:YES];
[archiv release];
在加载视图中:
firstPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 0, 768, 960)];
[firstPage setRootViewController:self];
secondPage = [[Page alloc] initViewWithFrame:CGRectMake(0, -960, 768, 960)];
[secondPage setRootViewController:self];
thirdPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 960, 768, 960)];
[thirdPage setRootViewController:self];
如果我现在再次点击一个按钮,活动页面会推送我的第三个 ViewController(调整大小、拖动的图像...):
Picture *pic = [[Picture alloc] initWithPicURLString:urlString];
[rootViewController.navigationController pushViewController:pic animated:YES];
[pic release];
使用 NavigationController 的 BackButton,我总是可以返回到上一个视图。
更多信息:
- 每个 ViewController 都支持所有方向
- 每个 ViewController 都实现
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation和return YES; - 每个 ViewControler 在其 init 方法中调用
[super init] - 我已经看过Apple's Q&A: Why won't my UIViewController rotate with the device
现在棘手的问题:
如果我从第二个 VC 切换到第三个 VC,将那里的方向从 portrait 更改为 landscape 并按 BackButton 一切正常工作(shouldAutorotateToInterfaceOrientation 正在调用,帧大小和原点变化...)。
但是如果我反其道而行之,我将处于 横向模式,从 2nd VC 切换到 3rd VC,旋转到纵向然后来使用 BackButton 回到第二个 VC,状态和控制器栏位于顶部,但 shouldAutorotateToInterfaceOrientation 没有被调用。
请帮助我。 $h@rky
【问题讨论】:
标签: ios xcode uinavigationcontroller orientation modalviewcontroller