我正在尝试在我的ViewController中的一个Swift应用程序中使用JawBone/JBChartView图表:
class ViewController: UIViewController , JBBarChartViewDelegate {
...
}我已经实现了符合协议的方法:
override func heightForBarViewAtIndex (bc: JBBarChartView , index: Int) -> Double{
//return 1;
}JBarChartViewDelegate是一个ObjectiveC类,所以要实现的最初方法是:
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index;我无法编译我得到的"ViewController不符合协议JBBarChartViewDelegate“的代码
我做错什么了?
提前谢谢。
发布于 2014-09-30 20:08:26
最后,问题是Int参数,它必须是Uint。因此,实现的最后方法是:
func barChartView(barChartView: JBBarChartView!, heightForBarViewAtIndex index: UInt) -> CGFloat{
return 0.0
}这对你们所有人都有好处。
发布于 2014-09-29 21:04:40
看起来你的问题可能是你使用了错误的类型。当声明指定一个Double时,返回值似乎是在重写函数中返回一个CGFloat。此外,我认为函数应该从声明的方法开始使用相同的单词。你写heightForBarViewAtIndex(的时候,我相信它会翻译成下面的样子。
试试这个:
override func barChartView(barChartView: JBBarChartView, heightForBarViewAtIndex index: UInt) -> CGFloat {
return 0.0
}https://stackoverflow.com/questions/26108790
复制相似问题