2012-08-31 43 views
1

我在我所有的控制器實現iPhone - 旋轉不工作

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return YES; 
} 

。我在info.plist中有4個方向,但我的應用程序不想旋轉。唯一旋轉的是頂欄。我的桌子視圖不旋轉...但我可以看到我的桌子後面的視圖,它旋轉像它應該但我無法訪問它,因爲我的原始表視圖(不旋轉)是正確的,並採取屏幕的95%。

This is about what it looks like

感謝您能給我任何支持!

+0

您的自動調整口罩如何設置? –

+0

self.menuTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;類似的東西?在shouldAutorotateToInterfaceOrientation中,我應該在哪裏放置這個...?我把它放在它裏面,但它似乎沒有太大的作用,所以我只是把它刪除了 –

+0

把它放在viewDidLoad中,並用所有的自動修復掩碼來嘗試它。使用:'self.menuTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin' – jere

回答

1

我有一個類似的problem,其中視圖不會自動旋轉。我沒有解決方案,但我有一個解決方法。在您的視圖控制器的willRotateToInterfaceOrientation,旋轉明確的觀點:

switch (toInterfaceOrientation) { 
     case UIInterfaceOrientationLandscapeLeft: 
      self.view.transform = CGAffineTransformMakeRotation(M_PI * 0.5); 
      break; 
     case UIInterfaceOrientationLandscapeRight: 
      self.view.transform = CGAffineTransformMakeRotation(M_PI * -0.5); 
      break; 
     case UIInterfaceOrientationPortrait: 
      self.view.transform = CGAffineTransformMakeRotation(0); 
      break; 
     case UIInterfaceOrientationPortraitUpsideDown: 
      self.view.transform = CGAffineTransformMakeRotation(M_PI * 1); 
      break; 
     default: 
      break; 
    } 

我打電話解決類似的問題,因爲我覺得視圖應該沒有明確的CGAffineTransformMakeRotation呼叫自動旋轉。在我的情況下,我正在實例化一個不同的風景視圖,我需要這樣旋轉。我有其他項目,其中單獨的視圖自動旋轉。我不知道爲什麼它不這樣做。

0

這可能有助於你

 if(interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation== UIInterfaceOrientationLandscapeRight||interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown) 
    { 

      return YES; 
    } 
+0

他會在哪裏把這個?他已經在所有方向的shouldAutorotateToInterfaceOrientation中返回YES。這沒有意義 – jere

1

在你ViewController.m類,你可能想要做的,而不是什麼是複製和粘貼出我的代碼,該viewDidDisapear方法如下如下圖所示:

/* 
- (void)viewDidDisappear:(BOOL)animated { 
    [super viewDidDisappear:animated]; 
} 
*/ 

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    return (interfaceOrientation == UIInterfaceOrientationPortrait || UIInterfaceOrientationLandscapeLeft || UIInterfaceOrientationLandscapeRight); 
} 

希望這有助於!

+0

改變後仍然無法工作,我不知道可能會導致這種情況。但我有點恨此刻:) –