我试图提供我自己的版本来覆盖这种行为,特别是告诉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
}
答案 0 :(得分:3)
只需删除括号,将func
替换为var
并使用冒号交换箭头,该方法已转换为属性:
override var shouldRemovePresentersView : Bool {
return false
}