ios - TextField 变得崩溃

标签 ios iphone swift uikeyboard

我有 ScrollView ,上面有多个文本字段。但是当我的 KeyBoard 显示我的所有文本字段和标签折叠时

 func keyboardWillShow(sender: NSNotification) {
            scroll.frame = CGRectMake(scroll.frame.origin.x, scroll.frame.origin.y, scroll.frame.size.width, self.view.frame.size.height - 216)
        }

        func keyboardWillHide(sender: NSNotification) {

            scroll.frame = CGRectMake(scroll.frame.origin.x, scroll.frame.origin.y, scroll.frame.size.width, self.view.frame.size.height)
        }

最佳答案

self.view.frame.size.height - 216)

你有没有注意到这一行中的这一部分

 scroll.frame = CGRectMake(scroll.frame.origin.x, scroll.frame.origin.y, scroll.frame.size.width, self.view.frame.size.height - 216)

当您出现键盘时,您正在更改 View 的高度。 并且也不要 checkin 模拟器。在实际设备上运行。

您需要以适当的方式处理它。例如:How do I scroll the UIScrollView when the keyboard appears?

关于ios - TextField 变得崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34528726/

相关文章:

ios - 从应用程序委托(delegate)调用时未加载调用工具包 ui

ios - iOS 7 中应用通知声音默认关闭

iphone - 使用 NSLayoutConstraints 在 UITextView 中居中 UILabel

iphone - 如何在 iPhone 应用程序中播放声音

iphone - 消息与电子邮件

ios - UICollectionView ImageView 问题

ios - 在iOS的按需资源中,有什么方法可以阻止清除/清除 Assets 吗?

ios - iOS模拟器安装证书失败

iphone - 选择器添加参数

ios - 在不停止整个程序的情况下延迟某个功能//Swift 4