方向景观->肖像功能不起作用
我还有另一个方向问题。但这是非常棘手的。 我的 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];
在 loadView 中:
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 的后退按钮,我始终可以返回到上一个视图。
更多信息:
- 每个 ViewController 支持所有方向
- 每个 ViewController 都实现
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
withreturn YES;
- 每个 ViewController 都会调用
[super init ]
在他们的 init-method 中 - 我已经读过 Apple 的问答:为什么我的 UIViewController 不随设备旋转
现在是棘手的问题:
如果我从第二个 VC 切换到第三个 VC,将方向从纵向更改为横向,然后按后退按钮,一切都会工作(shouldAutorotateToInterfaceOrientation
正在调用,帧大小和原点发生变化......)。 但是如果我反过来做,我会处于横向模式,从第二个 VC 切换到第三个 VC,旋转到纵向并且回到带有 BackButton 的 2nd VC,状态栏和控制器栏位于顶部,但 shouldAutorotateToInterfaceOrientation
未被调用。
请帮我。 $h@rky
I have another orientation problem. But this one is very tricky.
My RootViewController is a normal NavigationController.
self.window.rootViewController = _naviController;
which has another ViewController inside, lets call it VC1.
VC1 has some buttons and labels. Its like an overview with folders.
If I press a button I come to the next ViewController with 3 ViewController (Page) and another bunch of buttons (like inside a folder looking at the pictures/thumbnails inside):
Archiv *archiv = [[Archiv alloc] init];
[self.navigationController pushViewController:archiv animated:YES];
[archiv release];
in loadView:
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];
If I now click again on a button the active Page push my third ViewController (image with resizing, dragging...):
Picture *pic = [[Picture alloc] initWithPicURLString:urlString];
[rootViewController.navigationController pushViewController:pic animated:YES];
[pic release];
With the BackButton of the NavigationController I can always come back to the previous view.
Some more informations:
- Every ViewController supports all orientations
- Every ViewController implements
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
withreturn YES;
- Every ViewControler calls the
[super init]
in their init-methode - I already read Apple's Q&A: Why won't my UIViewController rotate with the device
Now the tricky problem:
If I switch from 2nd VC to the 3rd VC, change the orientation there from portrait to landscape and press the BackButton everything is working (shouldAutorotateToInterfaceOrientation
is calling, frame size and origins changing ...).
BUT if I do it the other way around, I am in landscape mode, switch from 2nd VC to 3rd VC, rotate to portrait and come back to 2nd VC with BackButton, the status- and controllerBar are at the top but the shouldAutorotateToInterfaceOrientation
wasn't called.
Please help me. $h@rky
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个,它对我有用:
Try this, it works for me:
今天灵机一动,在不知道原因的情况下解决了这个问题。
在我的第三个 VC 中,我刚刚创建了一个指向第二个视图的指针,并自己调用了shouldAutorotateToInterfaceOrientation。
但要点仍然是一样的:为什么
shouldAutorotateToInterfaceOrientation
在所描述的情况下不调用?亲切的问候。 $h@rky
Today I got the idea that solved the problem without knowing the cause.
In my third VC I just created a pointer to the 2nd View and called the
shouldAutorotateToInterfaceOrientation
myself.But the point is still the same: Why isn't
shouldAutorotateToInterfaceOrientation
not calling in the described situation?Kind regards. $h@rky
shouldAutorotateToInterfaceOrientation
仅在用户旋转时调用,因此当您从横向到纵向或以其他方式查看控制器仍为横向时,因此这解决了问题,您必须破解代码,这意味着当您从横向推动视图控制器时以肖像presentViewController为例:在ListViewController函数中调用:
并且您必须为UINavigationController创建类别
我希望这个解决方案对您有所帮助。
shouldAutorotateToInterfaceOrientation
only called when user rotate, so when you from landscape to portrait or otherwise then view controller still landscape, so this solve problem, you have to hack code, it's mean when you push to view controller from landscape to portrait presentViewController example:in ListViewController function called:
and you have to create category for UINavigationController
I hope this solve will help you.