2016-12-12 6 views
0

ではありません、私はダニエル・コーエンGindiによってオープンソースChartsを使用しています:https://github.com/danielgindi/Chartsは、もはや選択

私は上の円グラフを持っていますこのように、それ自体をグラフ私の画面:

//set pie chart data 
graphView.data = PieChartData(dataSets: iPieChartDataSet) 

さらに私はポップオーバーsimilarly to the accepted answer of this questionを表示する画面上のボタンを持っています。

「私が欲しいもの」 ユーザが画面上UIButtonを押すと、私はポップオーバーを表示したいです。

私はUIButtonを押すと、予想通り 、ポップオーバーが作成され、提示された「とは何の働き」。さらに、私はポップオーバーを作成して閉じ、再作成することができます。

「効果がない」 グラフが画面に存在する場合、ポップオーバーは表示されません。 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) 
} 

答えて

0

私のアプリのために、私はボタンを作成プログラム的に、私はこれまでのところ問題はなかった。 Heres私のボタンコードは、あなたのために動作するかどうかを参照してください。

var updateButton : UIButton = UIButton(type: .custom) 

override func viewDidLoad() { 
    super.viewDidLoad() 

    setChart() 

    let buttonHeight = 60.0 
    let buttonWidth = 280.0 
    let xspacing = 45.0 
    let fontSize:CGFloat = 30 
    let buttonColor = UIColor.black 
    let textColor = UIColor.blue 

    updateButton.frame = CGRect(x: xspacing, y: 400, width: buttonWidth, height: buttonHeight) 
    updateButton.backgroundColor = buttonColor 
    updateButton.clipsToBounds = true 
    updateButton.setTitle("Update", for: .normal) 
    updateButton.titleLabel!.font = UIFont(name: "ScienceFair", size: fontSize) 
    updateButton.titleLabel!.textColor = UIColor.black 
    updateButton.addTarget(self, action: #selector(updateFunc), for: .touchUpInside) 
    view.addSubview(updateButton) 

} 

func updateFunc() { 
    UIView.animate(withDuration: 0.1, animations: { self.updateButton.transform = CGAffineTransform(scaleX: 0.9, y: 0.9) }, completion: { (finish: Bool) in UIView.animate(withDuration: 0.1, animations: { self.updateButton.transform = CGAffineTransform.identity }) }) 
    //Present Popover 
} 

注釈付き#セレクタのstackoverflowフォーマットを無視します。そのコメントではありません。

関連する問題