使用iOS5在模态下的VIewController中不工作Orientation Notifications [英] Not working Orientation Notifications in VIewController under modal, with iOS5

查看:91
本文介绍了使用iOS5在模态下的VIewController中不工作Orientation Notifications的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我的英文.. :)

Excuse my English.. :)

在我的viewController(A)中有一个这样的方向通知器:

In my viewController (A) there is a orientation notifier like this:

 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{ UIDeviceOrientation newOrientation = [[UIDevice currentDevice] orientation];

if (newOrientation == UIDeviceOrientationUnknown || newOrientation == UIDeviceOrientationFaceUp || newOrientation == UIDeviceOrientationFaceDown) {
    UIInterfaceOrientation mainOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    newOrientation = (UIDeviceOrientation) mainOrientation;
}

当这是控制器时这是正常工作。

This is working properly when this is the controller.

有时会出现一个ModalViewController(B),这可以重定向到新的方向,并且做得很完美。但是,当这个模态被解除时,主视图控制器保持与之前相同的方向。

There is a ModalViewController (B) that sometimes appear, and this could be reoriented to new orientation, and do it perfect. BUT, when this modal is dismissed, the main view controller remains in the same orientation it was before.

通过断点控制我已经检查了上面方法中的代码没有被执行。

Controlling by breakpoints I´ve checked that the code in the method above is not being executed.

在实现IOS5 SDK之前,所有这一切都完美无缺。

All this has been working perfectly before I actualized IOS5 SDK.

(我由于CGPLOT问题,没有重构为AR​​C。
任何人都可以帮助我,或者遇到同样的问题?

(I´ve not refactoriced to ARC, because of CGPLOT issues). Any one could help me, or has suffered same issue?

显而易见的解决方案是从模态视图调用此方法......但是烦恼.. :(

The obvious solution is to call this method from the modal view... but it´s annoying..:(

非常感谢你,祝你有个美好的一天!

Thanks you very much and have a nice day!

推荐答案

使用

[[NSNotificationCenter defaultCenter] postNotificationName:@"changeOrientation" object:nil];

从视图中看到didRotate ...工作和其他课程使用:

from view where didRotate... worked and in other class use:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doWork) name:@"changeOrientation" object:nil];

来抓住这个事件。

ЛайтбрингерсЕГ-форума?

Лайтбрингер с ЕГ-форума?

这篇关于使用iOS5在模态下的VIewController中不工作Orientation Notifications的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆