横向方向的键盘问题 - Xcode - Swift [英] Keyboard Issue in Landscape Orientation - Xcode - Swift

查看:71
本文介绍了横向方向的键盘问题 - Xcode - Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个适用于我的 iOS 应用的共享扩展程序,并且该扩展程序需要使用键盘.似乎我无法控制扩展的视图控制器的方向,因此当设备处于横向模式时,键盘会侧向转动,但离开屏幕.这使得用户在横向模式下无法使用键盘.如何更改键盘在屏幕上的坐标,以及如何检测设备的方向?我对这个问题感到困惑,任何反馈都将不胜感激.

I have a Share extension for my iOS app and the extension requires the use of a keyboard. It seems as though I cannot control the orientation of the view controller of the extension, so when the device is put in landscape mode, the keyboard turns sideways, but off the screen. This makes it so that the user cannot use the keyboard when in landscape mode. How can I change the coordinates of the keyboard on screen, and how do I detect the orientation of the device? I am perplexed by this issue and any feedback would be appreciated.

推荐答案

  • 检测方向:

    • To detect the orientation:

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

    • 检测方向变化(在 UIViewController 中):

    • To detect the orientation change (in a UIViewController):

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

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

      You can detect the orientation change and the orientation you have

      这篇关于横向方向的键盘问题 - Xcode - Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆