2014-09-30 62 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"];