【问题标题】:Keyboard is upside down in UIViewControllerUIViewController 中的键盘倒置
【发布时间】:2012-11-16 18:08:05
【问题描述】:

我正在尝试更新我的应用程序以与新的 iPhone 5 一起使用,我的一些视图将键盘从视图顶部而不是底部放下。这里有一张图片可以更好地说明:

这在 iOS 6.0 之前有效,所以我猜它一定是新 API 中的某些东西导致了这个错误。我正在使用以下代码来支持 UIVeiwController 中的方向:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   // Return YES for supported orientations
   return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
           interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (BOOL)shouldAutorotate {
   return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskLandscape;
}

有没有其他人遇到过类似的问题?谢谢!

【问题讨论】:

  • 是否在自定义视图/窗口中并应用了转换?

标签: iphone objective-c uiviewcontroller ios6 uiinterfaceorientation


【解决方案1】:

我已尝试复制您的问题,但它在 iOS6 上对我很有用。我的建议可能不是很有帮助,但请查看该委托、合成和所有功能匹配。

【讨论】:

    【解决方案2】:

    我在question 找到了答案。通过更改我设置根 UI 视图控制器的一行代码来解决我的问题。

    改变这一行:

    [window addSubview:viewController.view];
    

    到这里:

    [window setRootViewController:viewController];
    

    【讨论】:

      【解决方案3】:

      Andrew,我还发现 iOS 6 中不推荐使用 shouldAutoROtateToInterfaceOrientation 方法。

      不管怎样,我看到你解决了你的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-05
        • 1970-01-01
        • 2019-08-06
        • 2017-06-09
        • 1970-01-01
        相关资源
        最近更新 更多