2015-05-27 2 views
0

У меня есть parentViewController, который вызывает модальный ViewController с делегатом UITableViewController. Проблема в том, что у меня нет навигационного стека, чтобы получить значение от родительского mustAUtoRotate.iOS8 Modal ViewController не срабатывает mustAutoRotate.

Поскольку shouldAutorotate никогда не срабатывал, он получает его от главного контроллера, где возвращается NO, и это невозможно изменить. Есть ли способ манипулировать модальным контроллером, чтобы получить правильное значение toAutorotate для YES?

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
[self.pv dismiss:YES]; 
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; 
} 
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
     if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { 
      //[self fullScreenAction:nil]; 
     } else { 
//   [self exitFullScreenAction:nil]; 
     } 
    } 
} 
-(BOOL)shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
     return UIInterfaceOrientationMaskAll; 
    } else { 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    } 
} 

//ios >=6 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || 
    (interfaceOrientation == UIInterfaceOrientationPortrait) || 
    (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

ответ

0

Мне удалось решить мою проблему, хотя это не лучшее решение, возможно, для некоторых это будет полезно.

Итак, я создаю новый контроллер категорий, чтобы использовать его для ручного вызова вызовов вращения.

.m

#import "UINavigationController+AutoRotate.h" 

@implementation UINavigationController (AutoRotate) 

- (BOOL)shouldAutorotate { 
    return YES; 
} 
- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskAll; 
} 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return UIInterfaceOrientationMaskAll; 
} 
@end 

и .h

#import <UIKit/UIKit.h> 

@interface UINavigationController (AutoRotate) 

- (BOOL)shouldAutorotate; 
- (NSUInteger)supportedInterfaceOrientations; 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation; 

@end 

И тогда Модальные работал он должен без навигационного контроллера.