【问题标题】:IOS How to Make Landspace Orientation in Every PageIOS如何在每个页面中设置横向
【发布时间】:2014-09-14 19:42:19
【问题描述】:

我正在制作一个 ios 应用程序,我想让所有页面都是陆地空间。 第一页是陆地空间,但第二页是纵向(通过按钮进入第二页)。 如何让它成为陆地空间。

(我没有使用故事板)

按钮点击事件:

PanelController *panel = [[PanelController alloc] init];
[self.navigationController pushViewController:panel animated:true];

【问题讨论】:

标签: ios iphone xcode


【解决方案1】:

这个怎么样?

-(void)viewWillAppear:(BOOL)animated
{
    UIApplication* application = [UIApplication sharedApplication];
    if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
    {
        UIViewController *controller = [[UIViewController alloc]init];
        [controller.view setBackgroundColor:[UIColor whiteColor]];
        [self.navigationController presentViewController:controller animated:NO completion:^{
            [self.navigationController dismissViewControllerAnimated:YES completion:^{
            }];
        }];
}

【讨论】:

    【解决方案2】:

    改变方向的正确技巧应该是这样的:

    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    

    【讨论】:

    • 我应该把它们放在哪里?
    • 我现在无法测试它,但我认为您应该在每个 .m 文件上的 ViewDidLoad 之后使用它。 (也许你只是在你的第一个 ViewController 上需要它,试试看!)
    • 另外,如果我的方法不起作用,请查看此答案! stackoverflow.com/questions/5777313/…
    猜你喜欢
    • 2019-07-23
    • 2014-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-26
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    相关资源
    最近更新 更多