#import <UIKit/UIKit.h>
@interface UINavigationController (autorotation)
-(BOOL)shouldAutorotate;
-(NSUInteger)supportedInterfaceOrientations;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
@end
#import "UINavigationController+autorotation.h"
#import "AboutViewController.h"
@implementation UINavigationController (autorotation)
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
我的问题是应用程序正在为所有屏幕旋转,但我想停止视图控制器v2的旋转,如上所述。我真的有两天请帮助我
答案 0 :(得分:0)
- (BOOL)shouldAutorotate
{
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[v2 class]])
return NO;
return YES;
}
//在您的代码中添加此方法并告诉我其工作与否。
答案 1 :(得分:0)
This is a useful link i used once它会对您提出的问题进行反思,但仍然可以使用它。
另一种方法是将此视图放在您不想旋转的视图中
- (BOOL) shouldAutorotate { return NO; }
不要忘记将视图旋转到适当的InterfaceOrientation,就像这样
[self willAnimateRotationToInterfaceOrientation:1 duration:1];
你可以将它放在viewWillApear;
中