1

私は問題があります。私のviewControllerのXibには複数のUIViewがあります。アプリは縦向きモードで起動し、横向きに回転できます。

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

}

ランドスケープ モードで UIButton を押してビューを変更すると、「新しい」ビューはポートレート モードのままになります。ビューを変更するコードは次のとおりです。

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

ビューを変更したときに正しい回転ビューを表示するにはどうすればよいですか?

4

2 に答える 2

0

この行をメソッドに追加します

-(IBAction) gotogame
{
     self.view = gameView;
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];
}
于 2012-06-22T12:21:36.813 に答える
0

私はこれを試しましたが、それは私のために働いています:

UIView *newView = [[UIView alloc] init];
newView.backgroundColor = [UIColor grayColor];
newView.frame = self.view.bounds;
[self.view addSubview:newView];
于 2012-06-22T12:38:43.880 に答える