swift - How can Upside Down orientation be continually detected on an iPhone in viewWillTransitionToSize:coordinator: on iOS 9? -


i’m handling rotation changes in viewwilltransitiontosize:coordinator: on iphone ios 9.1 , i’m able detect upside down orientation if device turned upside down, right side up, after starting app first time. further rotations upside down not result in further detections of upside down orientation.

i’m using following code in view controller:

override func viewwilltransitiontosize(size: cgsize,                                         withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) {     super.viewwilltransitiontosize(size, withtransitioncoordinator: coordinator)    

i have orientations checked off in general tab of xcode project.

i followed suggestion in accepted answer rotation behaving differently on ios6 , implemented own custom navigation controller.

class mynavigationcontroller: uinavigationcontroller {     override func shouldautorotate() -> bool {         return true     }      override func supportedinterfaceorientations() -> uiinterfaceorientationmask {         return uiinterfaceorientationmask.all     }     } 

that did not result in successful continual detection of upside down in viewwilltransitiontosize:coordinator:.

adding same methods view controller did not change results:

class myviewcontroller: uiviewcontroller {     override func shouldautorotate() -> bool {         return true     }      override func supportedinterfaceorientations() -> uiinterfaceorientationmask {         return uiinterfaceorientationmask.all     } 

setting separate observer using

nsnotificationcenter.defaultcenter().addobserver(self, selector: "deviceorientationdidchange:", name:uideviceorientationdidchangenotification, object: nil) uidevice.currentdevice().begingeneratingdeviceorientationnotifications() 

also not continually report upside down orientation when check bounds with:

uiscreen.mainscreen().bounds 

instead, bounds reported being same landscape.

ideally, have upside down handled viewwilltransitiontosize:coordinator: i’m open workarounds, too.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -