0

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?

Dean Lee
  • 781
  • 2
  • 7
  • 13

1 Answers1

1

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:

OOPer
  • 47,149
  • 6
  • 107
  • 142