Martin Bazire
Martin Bazire

Reputation: 17

Force portrait orientation IOS (swift)

I'm trying to force portrait orientation on iphone. So i try this :

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return .Landscape
}

But i have an error : "Method does not override any method from its superclass"

Upvotes: -2

Views: 166

Answers (2)

Rishabh Raghunath
Rishabh Raghunath

Reputation: 439

Use it like the below code snippet,

override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
    return .landscape
}

This has been converted into a property now and you should override them and return a value like a computed property. Since your question says you are trying to force a portrait orientation, you should return .portrait or UIInterfaceOrientationMask.portrait instead

Upvotes: 0

Ensar Baba
Ensar Baba

Reputation: 1

supportedInterfaceOrientations() is a function from UIViewController. If you are getting this error "Method does not override any method from its superclass" which means your class is not inherited from UIViewController. Maybe you can give additional info about the class you try to implement an orientation.

Upvotes: -1

Related Questions