Core-Plot внутри UICollectionViewCell - PullRequest
       25

Core-Plot внутри UICollectionViewCell

0 голосов
/ 07 сентября 2018

У меня есть UICollectionView, у которого есть график Core-Plot внутри одной из ячеек.

У меня нет проблем при создании графика Core-Plot в UIView, но у меня возникают проблемы с тем, чтобы этот график Core-Plot работал внутри UICollectionViewCell.

В MyCollectionViewCell.swift

import UIKit
import CorePlot

class MyCollectionViewCell: UICollectionViewCell {
    @IBOutlet weak var corePlot: CPTGraphHostingView!
}

В MyViewController.swift

import UIKit
import CorePlot

class MyViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {

...

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let theCell = collectionView.dequeueReusableCell(withReuseIdentifier: "MyCollectionViewCell", for: indexPath) as! MyCollectionViewCell
        let graph = CPTXYGraph(frame: theCell.corePlot.bounds)
        theCell.corePlot.hostedGraph = graph // This is where it crashes
        ...
    }

...

}
extension MyViewController: CPTScatterPlotDataSource, CPTScatterPlotDelegate {
    ...
}

- [UIView setHostedGraph:]: нераспознанный селектор отправлен в экземпляр 0x7f8a9aa20240

*** Завершение работы приложения из-за необработанного исключения «NSInvalidArgumentException», причина: '- [UIView setHostedGraph:]: нераспознанный селектор, отправленный экземпляру 0x7f8a9aa20240'

1 Ответ

0 голосов
/ 07 сентября 2018

Вам необходимо установить имя класса CPTGraphHostingView на corePlot

@IBOutlet weak var corePlot: CPTGraphHostingView!

Внутри xib-файла / прототипа ячейки в IB, здесь UIView в сбое

[UIView setHostedGraph:]

означает, что вы не присвоили его

...