I've been trying to use UIInterfaceOrientationMask in my Swift code. In Objective-C, I would use it as an enum, and when I needed to use, for example, the portrait mask, I would simply use UIPortraitOrientationMask
in my code, like so:
NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
I'm not quite sure what I'm supposed to do with the documentation, and I haven't been able to find anything about a "Raw Option Set" anywhere in the tutorial book or the documentation.
As of Xcode 7, Swift Version 2.0:
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { return UIInterfaceOrientationMask.Portrait }
Original obsolete answer below:
As of Xcode 6.2 or 6.3, or Swift version 1.2:
override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.Portrait.rawValue) }
supportedInterfaceOrientations
is defined to return an Int, but UIInterfaceOrientationMask
is an enumeration. So, use the rawValue
property of the enumeration to find its raw value, which gives a UInt. The Int() function takes the UInt as an input and returns an Int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With