2012-06-22 71 views
1

我有一個問題。 我的viewController的Xib有多個UIView。 該應用程序以縱向模式啓動,我可以將其旋轉爲橫向。同一個XIB中的多個視圖。問題時旋轉視圖和更改視圖

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

} 

當我在橫向模式下,我改變視圖按下一個UIButton,「新」的觀點還停留在人像模式.. 這裏是改變視圖代碼:

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

我想要查看正確的旋轉視圖,當我更改視圖 怎麼辦?

回答

0

這一行添加到您的方法

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

確定完成,但它轉動我iPhone(模擬器),但認爲沒有旋轉:( – Spale350z

+0

您是否以橫向模式或縱向創建了視圖? – Rajkumar

0

我嘗試這樣做,這是爲我工作:

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