【问题标题】:Multiple Views in same XIB. issue when rotate view and change view同一个 XIB 中的多个视图。旋转视图和更改视图时的问题
【发布时间】:2012-06-24 16:51:38
【问题描述】:

我有问题。 我的 viewController 的 Xib 有多个 UIView。 该应用程序以纵向模式启动,我可以将其旋转为横向。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES; // (interfaceOrientation == UIInterfaceOrientationPortrait);

}

当我处于横向模式并按下 UIButton 更改视图时,“新”视图仍处于纵向模式。 这是更改视图的代码:

-(IBAction) gotogame
{
     self.view = gameView;
}

我想在更改视图时看到正确的旋转视图 怎么办?

【问题讨论】:

    标签: iphone xcode uiview rotation


    【解决方案1】:

    将此行添加到您的方法中

    -(IBAction) gotogame
    {
         self.view = gameView;
    [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];
    }
    

    【讨论】:

    • 好的,但它旋转了我的 iPhone(模拟器),但视图没有旋转 :(
    • 您创建的视图是横向模式还是纵向模式?
    【解决方案2】:

    我试过了,它对我有用:

    UIView *newView = [[UIView alloc] init];
    newView.backgroundColor = [UIColor grayColor];
    newView.frame = self.view.bounds;
    [self.view addSubview:newView];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-20
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 2011-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多