【发布时间】:2018-09-07 00:00:23
【问题描述】:
我有一个UICollectionView,其中一个单元格内有一个核心图。
在 UIView 中制作 Core-Plot 图表时我没有任何问题,但我无法让此 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:]: unrecognized selector sent to instance 0x7f8a9aa20240'
【问题讨论】:
标签: ios swift uicollectionview core-plot