Morgan Wilde
Morgan Wilde

Reputation: 17303

I never get notified when device rotation is in .PortraitUpsideDown

I have the following method inside my only ViewController.

override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
    println("willAnimateRotationToInterfaceOrientation")
    super.willAnimateRotationToInterfaceOrientation(toInterfaceOrientation, duration: duration)

    switch (toInterfaceOrientation) {
    case .Portrait: println(".Portrait")
    case .PortraitUpsideDown: println(".PortraitUpsideDown")
    case .LandscapeRight: println(".LandscapeRight")
    case .LandscapeLeft: println(".LandscapeLeft")
    case .Unknown: println(".Unknown")
    }
}

And I enabled all possible orientations in the project settings

Settings

But even if I rotate 360 in the simulator (same goes for my iPhone), I never get ".PortraitUpsideDown" printed in the console. Why? It almost seems, like Apple doesn't allow this rotation.

Upvotes: 0

Views: 116

Answers (1)

David Wong
David Wong

Reputation: 10294

You need to specifically return portrait upside down in supportedInterfaceOrientations() in your base UIViewController

The method implementation should look like so.

override func supportedInterfaceOrientations() -> Int {
    return Int(UIInterfaceOrientationMask.All.rawValue)
}

Upvotes: 1

Related Questions