Not working Orientation Notifications in VIewController under modal, with iOS5

自古美人都是妖i 提交于 2019-12-11 01:08:20

问题


Excuse my English.. :)

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.

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.

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

(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!


回答1:


Send a notification using

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

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

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

to catch this event.

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



来源:https://stackoverflow.com/questions/7846565/not-working-orientation-notifications-in-viewcontroller-under-modal-with-ios5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!