rawValue属性在哪里?

时间:2016-03-22 20:54:48

标签: ios swift

我创建了一个非常简单的应用程序,限制了您可以旋转iPhone的方向。在ViewController中,我重写方法supportedInterfaceOrientations,如下所示:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

    return UIInterfaceOrientationMask(rawValue: (UIInterfaceOrientationMask.Portrait.rawValue | UIInterfaceOrientationMask.LandscapeLeft.rawValue ))

} 

当我查看UIInterfaceOrientationMask的实现时:

public struct UIInterfaceOrientationMask : OptionSetType {
    public init(rawValue: UInt)

    public static var Portrait: UIInterfaceOrientationMask { get }
    public static var LandscapeLeft: UIInterfaceOrientationMask { get }
    public static var LandscapeRight: UIInterfaceOrientationMask { get }
    public static var PortraitUpsideDown: UIInterfaceOrientationMask { get }
    public static var Landscape: UIInterfaceOrientationMask { get }
    public static var All: UIInterfaceOrientationMask { get }
    public static var AllButUpsideDown: UIInterfaceOrientationMask { get }
}   

我找不到属性rawValue,例如Portrait属性。 rawValue来自哪里?

1 个答案:

答案 0 :(得分:1)

回到这个:

return [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.LandscapeLeft]

将原始价值转换回原始价值是没有意义的! :)