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

问题描述 投票:0回答:1

这是我之前正在使用的代码。

NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: Notification.Name.UIDevice.orientationDidChangeNotification, object: nil)
swift swift4.2
1个回答
6
投票

删除Notification.Name.前缀:

NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: UIDevice.orientationDidChangeNotification, object: nil)

通知名称的常量在Xcode 10附带的iOS 12 SDK中移动。

© www.soinside.com 2019 - 2024. All rights reserved.