0

我正在开发一个应用程序,在该应用程序中单击按钮时,我必须将一个类控制器视图显示为子视图。我已将我的视图控制器添加为子视图,它工作正常。

TempViewControlleriPad *tempScreen=[[TempViewControlleriPad alloc]initWithNibName:@"TempViewControlleriPad" bundle:nil];
[self.view addSubview:tempScreen.view];
[tempScreen viewWillAppear:NO];

现在,当我旋转设备方向时,我的子视图没有响应该方向意味着我的子视图没有旋转。

TempViewControlleriPad orientation method:-


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
             [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPad" owner:self options:nil];
    }
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
         [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPadLandscape" owner:self options:nil];
    }

    return YES;

}

请建议我应该怎么做才能解决这个方向问题。

提前致谢。

4

1 回答 1

1

子视图的控制器是 UIViewController 吗?您不应该在另一个中嵌入视图控制器。来自苹果文档:

您不应使用多个自定义视图控制器来管理同一视图层次结构的不同部分。同样,您不应该使用单个自定义视图控制器对象来管理多个屏幕的内容。 http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html#//apple_ref/doc/uid/TP40007457-CH112-SW12

您可以在子视图上设置自动调整大小掩码。

于 2011-10-07T06:44:52.897 回答