ios - self.view.bounds.maxY 仅适用于 viewDidLoad() 之外

标签 ios swift custom-keyboard

我正在尝试使用

调整自定义键盘扩展的大小
self.view.bounds.maxY

但是,该代码似乎只能在

之外工作
viewDidLoad()

在保存 View 的高度后,有没有办法再次通过 viewDidLoad ?

除了使用通知之外,还有其他方法获取键盘矩形的高度吗?

最佳答案

您可以使用 UIScreen.main.bounds.height ,它与 self.view.bounds.maxY 相同,假设它是全屏 VC ,否则在内部访问它viewDidLayoutSubviews

Is there a way to go through viewDidLoad again after I have saved the height of my view?

是的,你可以,但调用应该由系统调用的方法不是一个好主意

Is there another way to get the height of the keyboard rectangle other than using the notifications?

没有

关于ios - self.view.bounds.maxY 仅适用于 viewDidLoad() 之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56047906/

相关文章:

ios - 播放 15 秒 mp3 ios

ios - 播放 mp3 音频时显示字幕

ios8 - 键盘扩展中的 IOS 8 应用程序组访问容器应用程序文件

ios - nscoder swift 不能发送到 NSCoder 类的抽象对象

android - 在 react-native 中渲染图表

ios - 我需要将哪些 serviceUUID 传递给 retrieveConnectedPeripheralsWithServices 以快速获取任何连接的设备?

swift - UIPopoverController、Xcode 6、使用 Swift 的 IOS 8

Swift常量哪个更好?

swift - 在 swift Playground 中使用 Type T

ios - 当我的自定义键盘显示在屏幕上时会调用哪个方法?