当我添加设备方向更改通知时,如下所示:
NSNotificationCenter.defaultCenter().addObserver(self,
selector: Selector(layoutPages),
name: UIDeviceOrientationDidChangeNotification as String!,
object: UIDevice.currentDevice())
我得到一个错误“UIDevice与anyobject不相同”,那么如何修复它?
最佳答案
第二个参数有问题,应该是字符串。此外,将UIDevice向上投射到任何对象都将有助于:
NSNotificationCenter.defaultCenter().addObserver(self,
selector: Selector("layoutPages"),
name: UIDeviceOrientationDidChangeNotification as NSString!,
object: UIDevice.currentDevice() as AnyObject)
关于ios - 如何设置通知对象的“UIDevice.currentDevice()”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25008975/