我的应用程序中有多个故事板,我希望将故事板方向保持为纵向。 有可能吗?如果是的话怎么样?
提前致谢。
答案 0 :(得分:0)
您可以做什么...(以下是仅适用于横向广告的示例)
创建自定义导航控制器
#import <UIKit/UIKit.h>
@interface CustomNavigationController : UINavigationController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;
@end
- (BOOL)shouldAutorotate
{
return [self.visibleViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations
{
if (![[self.viewControllers lastObject] isKindOfClass:NSClassFromString(@"ViewController")])
{
return UIInterfaceOrientationMaskLandscape;
}
else
{
return [self.topViewController supportedInterfaceOrientations];
}
}
在您只想要横向的所有文件中包含以下内容...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"1. shouldAutorotateToInterfaceOrientation");
if (interfaceOrientation==UIInterfaceOrientationMaskPortrait) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
||(interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)shouldAutorotate
{
return YES;
}