Protokoły Swift: metoda nie nadpisuje żadnej metody ze swojej superklasy

Ponieważ Xcode 6 nadal ma wiele błędów z Swift, nie jestem pewien, czy to jeden lub coś mi umyka. Moja klasa przyjmuje protokół NSLayoutManagerDelegate. Ale wydaje się niemożliwe obejście metody, której potrzebuję. Robię tak jak opisuje dokumentacja:

override func layoutManager(_ aLayoutManager: NSLayoutManager!,
        didCompleteLayoutForTextContainer aTextContainer: NSTextContainer!,
        atEnd flag: Bool) {

    }

Ale dostaję tutaj błąd: metoda nie nadpisuje żadnej metody ze swojej klasy nadrzędnej. Co mam zrobić?

Author: Vitaliy Vashchenko, 2014-06-24

2 answers

Implementujesz metodę z protokołu, tak, ale to nie jest obejście. Po prostu usuń słowo kluczowe override. Nadpisanie występuje wtedy, gdy Klasa superclass również implementuje tę metodę i dostarczasz wersję, która zastępuje lub modyfikuje zachowanie implementacji klasy superclass. Nie o to chodzi.

 79
Author: Ken Thomases,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-24 07:26:12

Z kodem x 9.1 try

override func viewDidLoad() {
    super.viewDidLoad()
    // Force the device in portrait mode when the view controller gets loaded
    UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")      
}



override var  shouldAutorotate:Bool {
    // Lock autorotate
    return true
}

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .landscape
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
    return .landscapeRight
}
 0
Author: ASHISHT,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-04 05:38:26