类型“ Notification.Name”(又名“ NSNotification.Name”)没有成员“ UIDevice”

Cod*_*ter 2 swift swift4.2

这是我以前工作的代码。

NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: Notification.Name.UIDevice.orientationDidChangeNotification, object: nil)
Run Code Online (Sandbox Code Playgroud)

Sul*_*han 9

删除Notification.Name.前缀:

NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: UIDevice.orientationDidChangeNotification, object: nil)
Run Code Online (Sandbox Code Playgroud)

通知名称的常量已在Xcode 10随附的iOS 12 SDK中进行了移动。