In inital ViewContoller UIDeviceOrientationDidChange with rxSwift has might be some glitch...
UIDeviceOrientationDidChange with rxSwift is very useful.
Here is some example code.
let name = NSNotification.Name.UIDeviceOrientationDidChange
let notificationRx = NotificationCenter.default.rx.notification(name).takeUntil(rx.deallocated)
_ = notificationRx.skip(0.5, scheduler: MainScheduler.instance).subscribe { notification in
switch UIDevice.current.orientation {
case .portrait, .landscapeLeft, .landscapeRight:
print(UIDevice.current.orientation, UIScreen.main.bounds.size)
completion(UIDevice.current.orientation)
default:
break
}
}
Rotate device portrait to landscape in inital ViewContoller, print log is display like this.
(375.0, 812.0)
(375.0, 812.0)
(375.0, 812.0)
(812.0, 375.0)
It could be occur some timing issue…
But Rotate device portrait to landscape not in inital ViewContoller, print log is display like this.
(812.0, 375.0)
(812.0, 375.0)
(812.0, 375.0)
(812.0, 375.0)
Yeah!, this is result, what i want.
I Don’t know why rxSwift acting like this.