【发布时间】:2016-06-05 04:16:18
【问题描述】:
我按照这个post 来实现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协议类里没找到。
【问题讨论】:
-
您不能在
arrowOffset设置器中执行super.arrowOffset = newValue。超类 setter 抛出异常。 -
@dan 你能给出一个答案来说明我应该怎么做吗?
标签: ios uipopovercontroller uipopoverbackgroundview