无法覆盖存储的属性shouldRemovePresentersView()

时间:2016-12-05 20:20:47

标签: ios swift swift2 swift3

我试图提供我自己的版本来覆盖这种行为,特别是告诉UIKit让MyController保持可见。

import UIKit

class DimmingPresentationController: UIPresentationController {

    override var shouldRemovePresentersView: Bool

}

但我收到了一些错误,例如:

Cannot override with a stored property 'shouldRemovePresentersView'
Getter for 'shouldRemovePresentersView' with Objective-C selector 'shouldRemovePresentersView' conflicts with getter for 'shouldRemovePresentersView' from superclass 'UIPresentationController' with the same Objective-C selector

实际上,我正在改写Swift 2方法,这对swift 3来说不方便了:

override func shouldRemovePresentersView() -> Bool {
return false
}

1 个答案:

答案 0 :(得分:3)

只需删除括号,将func替换为var并使用冒号交换箭头,该方法已转换为属性:

override var shouldRemovePresentersView : Bool {
    return false
}