2

例如,我使用此代码关闭自动旋转

- (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

4

2 回答 2

1

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

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

尝试以下代码

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
于 2013-11-06T12:04:38.783 回答
1

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

    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];
}

希望这对某人有帮助!)

于 2013-11-07T01:09:50.600 回答