【问题标题】:Can I change the keyboard orientation?我可以更改键盘方向吗?
【发布时间】:2013-11-17 13:39:51
【问题描述】:

例如我用这段代码关闭自动旋转

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}
-(BOOL)shouldAutorotate
{
    return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return 0;
}

而且我的按钮、标签、textFields 和其他对象可以根据设备的当前方向旋转。但是键盘不想旋转=/ 我如何可以旋转键盘或我不能。谁知道? 请帮忙) http://www.pictureshack.ru/images/8145_Snimok_ekrana_05_11_2013_18_55_00_s_Simulyatora_iOS.png

【问题讨论】:

    标签: ios xcode keyboard orientation


    【解决方案1】:

    键盘方向与状态栏方向相同。

    在图像中,您的所有按钮和文本方向都不是状态栏的方向。

    试试下面的代码

    -(BOOL)shouldAutorotate
    {
        return NO;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
    

    【讨论】:

    • 哦,不是很有帮助的代码,但是……但是!你给我一个解决问题的提示!
    【解决方案2】:

    好的。事实证明,决定很简单。 在我检查设备方向的方法中,我添加了此代码并且它正在工作。

        if (deviceOrientation == UIDeviceOrientationPortrait){
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
        }
        else if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown){
            [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown animated:NO];  
        }
        else if (deviceOrientation == UIDeviceOrientationLandscapeLeft){
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
        }
        else if (deviceOrientation == UIDeviceOrientationLandscapeRight){
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
    }
    

    希望这对某人有所帮助!)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      • 2013-10-11
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      • 2017-11-04
      相关资源
      最近更新 更多