当我添加设备方向更改通知时,如下所示:
NSNotificationCenter.defaultCenter().addObserver(self,
selector: Selector(layoutPages),
name: UIDeviceOrientationDidChangeNotification as String!,
object: UIDevice.currentDevice())
我收到错误' UIDevice与anyobject'不完全相同,那么如何解决?
答案 0 :(得分:0)
你的第二个参数有问题,它应该是一个字符串。此外,将UIDevice向上转换为AnyObject将有所帮助:
NSNotificationCenter.defaultCenter().addObserver(self,
selector: Selector("layoutPages"),
name: UIDeviceOrientationDidChangeNotification as NSString!,
object: UIDevice.currentDevice() as AnyObject)