gpt4 book ai didi

ios - 横向键盘问题 - Xcode - Swift

转载 作者:行者123 更新时间:2023-11-28 07:08:32 24 4
gpt4 key购买 nike

我的 iOS 应用程序有一个共享扩展程序,该扩展程序需要使用键盘。好像我无法控制扩展的 View Controller 的方向,所以当设备处于横向模式时,键盘转向侧面,但不在屏幕上。这使得用户在横向模式下无法使用键盘。如何更改键盘在屏幕上的坐标,以及如何检测设备的方向?我对这个问题感到困惑,如有任何反馈,我们将不胜感激。

最佳答案

  • 检测方向:

    if(UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation))
    {
    println("landscape")
    }

    if(UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation))
    {
    println("portrait")
    }
  • 检测方向变化(在 UIViewController 中):

    override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
    // your code
    }

您可以检测方向变化和您拥有的方向

关于ios - 横向键盘问题 - Xcode - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29495554/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com