我按照这篇文章来实现一个UIPopoverBackgroundView
. 我检查了这个UIPopoverBackgroundView
类,我想我已经实现了所有必需的函数和变量,但是运行时错误仍然存在。
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“-[UIPopoverBackgroundView setArrowOffset:] 必须由子类实现。”
import UIKit
class CustomPopoverBackground: UIPopoverBackgroundView {
override func layoutSubviews() {
super.layoutSubviews()
}
override var arrowOffset: CGFloat {
get {
return 0.0
}
set {
super.arrowOffset = newValue
}
}
override var arrowDirection: UIPopoverArrowDirection {
get {
return UIPopoverArrowDirection.Up
}
set {
super.arrowDirection = newValue
}
}
override class func contentViewInsets() -> UIEdgeInsets {
return UIEdgeInsetsMake(10, 10, 10, 10)
}
override class func arrowBase() -> CGFloat {
return 2.0
}
override class func arrowHeight() -> CGFloat {
return 2.0
}
}
我哪里错了?什么是setArrowOffset
,我没有在类UIPopoverBackgroundView
或UIPopoverBackgroundViewMethods
协议中找到它。