类型 'Notification.Name'(又名 'NSNotification.Name')没有成员 'UIDevice'
Type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIDevice'
这是我之前运行的代码。
NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: Notification.Name.UIDevice.orientationDidChangeNotification, object: nil)
删除 Notification.Name.
前缀:
NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: UIDevice.orientationDidChangeNotification, object: nil)
通知名称的常量已移至 iOS 12 SDK 中 Xcode 10.
2020 年 4 月 9 日,我 运行 遇到了类似的问题。我有:
name: Notification.Name.UIKeyboardWillHide
我不得不 "Replace 'UIKeyboardWillHide' with 'UIResponder.keyboardWillHideNotification'"
我点击 "fix" 得到:
name: Notification.Name.UIResponder.keyboardWillHideNotification,
之后我得到了"Type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIResponder'"。最后,感谢你们,我想通了:
name: UIResponder.keyboardFrameEndUserInfoKey.
也许我的案例和答案对一些初学者也有帮助))
这是我之前运行的代码。
NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: Notification.Name.UIDevice.orientationDidChangeNotification, object: nil)
删除 Notification.Name.
前缀:
NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: UIDevice.orientationDidChangeNotification, object: nil)
通知名称的常量已移至 iOS 12 SDK 中 Xcode 10.
2020 年 4 月 9 日,我 运行 遇到了类似的问题。我有:
name: Notification.Name.UIKeyboardWillHide
我不得不 "Replace 'UIKeyboardWillHide' with 'UIResponder.keyboardWillHideNotification'" 我点击 "fix" 得到:
name: Notification.Name.UIResponder.keyboardWillHideNotification,
之后我得到了"Type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIResponder'"。最后,感谢你们,我想通了:
name: UIResponder.keyboardFrameEndUserInfoKey.
也许我的案例和答案对一些初学者也有帮助))