Dean Lee
Dean Lee

Reputation: 821

Swift 2 upgrade Swift 3 compile error in many method such as willTransitionToTraitCollection:newCollection:withTransitionCoordinator

When I used swift 3 to run some old code, and convert them to newest swift 3. I found the method compile error

    override func willTransitionToTraitCollection( newCollection: UITraitCollection,
      withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
}

And compiler told me "Method does not override any method from its superclass"

should I import some modules?

Upvotes: 0

Views: 350

Answers (1)

OOPer
OOPer

Reputation: 47896

In the Swift editor of my Xcode 8 beta 3:

class MyViewController: UIViewController {
    //Wait hear  ↓
    willTransition
}

I have got this suggestion:

class ViewController: UIViewController {
    //Wait hear  ↓
    override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
        <#code#>
    }
}

(You need to remove all other syntax errors to get better suggestions.)

Anyway, you should not do everything by yourself. Make Swift do it.


New documentation for willTransitionToTraitCollection:withTransitionCoordinator: is here:

willTransitionToTraitCollection:withTransitionCoordinator:

Upvotes: 1

Related Questions