2
iPhoneを回転できる方向を制限したとてもシンプルなアプリを作成しました。rawValueプロパティはどこですか?
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask(rawValue: (UIInterfaceOrientationMask.Portrait.rawValue | UIInterfaceOrientationMask.LandscapeLeft.rawValue))
}
そして、私はUIInterfaceOrientationMaskの実装を見ると:のViewControllerでは、私は次のようにメソッドをオーバーライドしsupportedInterfaceOrientations
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 }
}
私は例Portrait
プロパティのプロパティrawValue
上を見つけることができません。どこrawValue
から来る?
私は何かが足りないかもしれませんが、 '[UIInterfaceOrientationMask]'ではなく 'UIInterfaceOrientationMask'型のものを返す必要はありませんか? –
UIInterfaceOrientationMask型のものを返しています。この魔法は、ArrayLiteralConvertibleであるOptionSetTypeによって処理されます。配列リテラルの変換では、メンバーはセットのように扱い、それらを適切な型の適切な値に結合します。 Google OptionSetTypeを使用して、ネット上で利用可能なチュートリアルの一部を読んでください。 –