简体   繁体   中英

Cant detect orientation on the ios simulator?

I tried :

if UIDevice.current.orientation == UIDeviceOrientation.portraitUpsideDown {

print ("UpsideDown")
}

I have rotated the simulator UpsideDown ,but It looks like the simulator cant catch that. I dont know if this works in real device .. I have no device to test that. Is this a simulator bug ? what can I do to detect the orientation ?

By default when xcode creates your project, it doesn't enable portrait upside down orientation. You can enable the same in Build Settings -> Deployment Info -> Device Orientation . Please see below the screenshot:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM