如何解决与UIResponder无法识别此问题? [英] How to fix this issue with the UIResponder as not recognized?

查看:228
本文介绍了如何解决与UIResponder无法识别此问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Swift中制作一个NotePad应用程序,并且遇到了以下问题:

I'm making a NotePad application in Swift and I get the following issue:

类型"Notification.Name"(也称为"NSNotification.Name")没有成员"UIResponder"

type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIResponder'

这些是我键入的代码行:

Those are the lines of code I typed on:

@objc func updateTextView (notification : Notification) {
    let userInfo = notification.userInfo!

    let keyboardEndFrameScreenCoordinates = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
    let keyboardEndFrame = self.view.convert(keyboardEndFrameScreenCoordinates, to: view.window)

    if notification.name == Notification.Name.UIResponder.keyboardWillHideNotification {
        textView.contentInset = UIEdgeInsets.zero
    } else {
        textView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardEndFrame.height, right: 0)
        textView.scrollIndicatorInsets = textView.contentInset
    }

    textView.scrollRangeToVisible(textView.selectedRange)
}

推荐答案

尝试一下:

if notification.name == UIResponder.keyboardWillHideNotification {

...

这篇关于如何解决与UIResponder无法识别此问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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