2014-09-30 60 views
2

在我們的應用程序中,我們總是強制屏幕的方向。在iOS8之前,鍵盤的方向與狀態欄的方向有關,但現在iOS8似乎並不是這種情況。iOS8鍵盤方向

現在我們看到的情況是,我們的屏幕(和狀態欄)將在橫向上正確定向,但鍵盤仍然是縱向。爲了更正,我們必須在鍵盤顯示在橫向之前將設備從橫向移動到縱向。

如果鍵盤方向不再綁定到狀態欄有沒有辦法強制鍵盤的方向?

編輯: 此代碼在iOS6和7下工作。它用於更改狀態欄(用於更改鍵盤方向)的方向並轉換屏幕。

 [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; 
     if(isIpad()) 
     { 
      self.navigationController.view.center = CGPointMake(374.0, 512.0); 
      self.navigationController.view.transform = CGAffineTransformMakeRotation(GlobalInfo::degreesToRadians(90)) ; 
      self.navigationController.view.bounds = CGRectMake(0, 0, 1024, 748); 
     } 
     else 
     { 
      self.navigationController.view.center = CGPointMake(150.0, 240.0); 
      self.navigationController.view.transform = CGAffineTransformMakeRotation(GlobalInfo::degreesToRadians(90)) ; 
      self.navigationController.view.bounds = CGRectMake(0, 0, 480, 300); 
     } 
+0

歡迎來到StackOverflow。你能否說出你的問題,說明你已經嘗試了什麼,或者你研究了什麼?這個問題似乎過於寬泛。 – Sablefoste 2014-09-30 20:27:08

+0

謝謝,我添加了我們用來轉換屏幕的代碼。 – Emmo213 2014-10-01 12:16:48

回答

1

Pre-iOS8它們的鍵盤方向與狀態欄的方向相關,但在iOS8中,它與設備的方向相關。您可以用下面的代碼強制設備的方向。

// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa). 
// This is because rotating the device to the left requires rotating the content to the right. 

[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];