我使用的是开源由丹尼尔·科恩Gindi Charts
:https://github.com/danielgindi/Charts从“由丹尼尔·科恩Gindi图表”图形本身图形之后,屏幕上一个UIButton不再选择
我有一个饼图我的屏幕以及图形本身是这样的:
//set pie chart data
graphView.data = PieChartData(dataSets: iPieChartDataSet)
另外我有一个显示酥料饼similarly to the accepted answer of this question屏幕上的按钮。
“我想要” 当用户按下屏幕上的UIButton
,我想酥料饼的显示。
“什么可行” 当我按UIButton
,弹出窗口创建并按预期呈现。此外,我可以创建popover,关闭它并重新创建它。
“什么不起作用” 如果图形出现在屏幕上,则弹出窗口不会出现。我试图在UIButton
内使用print
语句,看起来IBAction
从未被解雇。
其他信息 其他UI操作工作。我可以标签到其他标签,我可以旋转图表。看起来如果屏幕上的图形存在,UIButton
会以某种方式关闭。
相关代码: 正在如何创建酥料饼:
@IBAction func informationButtonTapped(_ sender: UIButton) {
var popoverContent = (self.storyboard?.instantiateViewController(withIdentifier: segueIdentifiers.informationPopover))! as UIViewController
var nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.popover
var popover = nav.popoverPresentationController
popoverContent.preferredContentSize = CGSize(width: 500,height: 600)
popover?.delegate = self
popover?.sourceView = self.view
popover?.sourceRect = CGRect(x: 0, y: 0, width: 100, height: 100)
self.present(nav, animated: true, completion: nil)
}
被如何创建的图形(简称尽可能):
private func setChart(dataPoints: [String?], values: [Double]) {
var dataEntries: [PieChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = PieChartDataEntry(value: values[i], label: dataPoints[i])
dataEntries.append(dataEntry)
}
let pieChartDataSet = PieChartDataSet(values: dataEntries, label: "")
var iPieChartDataSet: [IChartDataSet] = []
iPieChartDataSet.append(pieChartDataSet)
graphView.animate(xAxisDuration: 1.0, yAxisDuration: 1.0)
graphView.layer.borderWidth = 0.1
//set pie chart data
graphView.data = PieChartData(dataSets: iPieChartDataSet)
}