我在两周内遇到了麻烦,所以请让我提问.
情况
XCode 7.2 Apple Swift 2.1.1版(swiftlang-700.1.101.15 clang-700.1.81) https://github.com/yosuke1985/ios-charts
iOS Chart ttps://github.com/danielgindi/ios-charts
这段代码来自
TTP://www.appcoda.com/ios-charts-api-tutorial/
我想要的是
我想使用这个框架,但错误是EXEC_BAC_ACCESS,
我只通过StoryBoard将窗口对象放在Viewcontroller上,并作为BarChartView类连接.
并且想要显示条形图,当我更改属性时,"noDataText"和"noDataTextDescription"它不起作用,并且无法弄清楚错误来自.
barChartView.noDataText = "there is no data" barChartView.noDataTextDescription = "give me the reason"
只有这些代码不起作用,我开始认为问题来自Swift或XCode的版本?请给我建议解决这个问题.
错误
EXEC_BAC_ACCESS ERROR,屏幕截图
import UIKit import Charts class ViewController: UIViewController { var months: [String]! @IBOutlet weak var barChartView: BarChartView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. barChartView.noDataText = "there is no data" barChartView.noDataTextDescription = "give me the reason" self.months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0] setChart(months, values: unitsSold) } func setChart(dataPoints: [String], values: [Double]) { barChartView.noDataText = "You need to provide data for the chart." var dataEntries: [BarChartDataEntry] = [] for i in 0..
小智.. 5
解决了.您需要设置条形图类视图,让故事板知道要初始化哪个类.自定义类现在为空,这意味着它将初始化为UIView并用作BarChartView.见http://i.imgur.com/c4tLNjL.png
1> 小智..:解决了.您需要设置条形图类视图,让故事板知道要初始化哪个类.自定义类现在为空,这意味着它将初始化为UIView并用作BarChartView.见http://i.imgur.com/c4tLNjL.png