我正在使用 danielgindi/Charts 的 ios-Charts。在 ChartValueSelected:chartView:entry:highlight 中添加 BalloonMarker.swift 的对象时,xcode 会生成 Command failed due to signal: Segmentation failure: 11 错误。
这表明:
1. While type-checking 'draw' at /Users/shenkor/Documents/Apps/Test/iOSCharts/iOSCharts/BalloonMarker.swift:72:19
2. While type-checking expression at [/Users/shenkor/Documents/Apps/Test/iOSCharts/iOSCharts/BalloonMarker.swift:158:9 - line:158:61] RangeText="label.draw(in: rect, withAttributes: _drawAttributes)"
当我在 BalloonMarker.swift 中用“label.draw(in: rect, withAttributes: _drawAttributes)”注释该行时,错误将消失,并且项目将正常构建,只是气球不显示任何值。
我使用的chartValueSelected:chartView:entry:highlight中的行是:
let marker: BalloonMarker = BalloonMarker(color: UIColor.darkGray, font: UIFont.systemFont(ofSize: 12.0), textColor: UIColor.white, insets: UIEdgeInsets(top: 7.0, left: 7.0, bottom: 7.0, right: 7.0))
marker.minimumSize = CGSize(width: 75, height: 35)
marker.setLabel(forString: "\(entry.y)")
chartView.marker = marker
chartView.marker?.refreshContent(entry: entry, highlight: highlight)
setLabel:newLabel中的三行:
_drawAttributes[.font] = self.font
_drawAttributes[.paragraphStyle] = _paragraphStyle
_drawAttributes[.foregroundColor] = self.textColor
也有错误:
Ambiguous subscript with base type '[NSAttributedStringKey : Any]' and index type '_',
我使用的是xcode8.3.3
请帮忙。
最佳答案
如果有人遇到同样的问题,我已经解决了这个问题。我使用的是 iOS-Charts 4.0.0 版本,该版本针对 swift4 进行了更新。由于我使用的是 swift 3,因此我必须从 iOS-Charts v3.0.2 获取 BallonMarker.swift,一切都开始工作。
关于ios-charts BalloonMarker.swift 由于信号 : Segmentation fault: 11,命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49468628/