- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES; // (interfaceOrientation == UIInterfaceOrientationPortrait);
}
当我处于横向模式并按下UIButton更改视图时,“新”视图仍保留在纵向模式下。 这是改变视图的代码:
-(IBAction) gotogame
{
self.view = gameView;
}
我希望在更改视图时看到正确的旋转视图 怎么办呢?
答案 0 :(得分:0)
将此行添加到您的方法
-(IBAction) gotogame
{
self.view = gameView;
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];
}
答案 1 :(得分:0)
我尝试了这个,它对我有用:
UIView *newView = [[UIView alloc] init];
newView.backgroundColor = [UIColor grayColor];
newView.frame = self.view.bounds;
[self.view addSubview:newView];