gpt4 book ai didi

ios - UICollectionViewCell 中的 Core-Plot

转载 作者:行者123 更新时间:2023-11-28 14:15:32 25 4
gpt4 key购买 nike

我有一个 UICollectionView,其中一个单元格内有一个 Core-Plot 图。

UIView 中制作 Core-Plot 图表时我没有遇到任何问题,但是我在让这个 Core-Plot 图表在 UICollectionViewCell 中工作时遇到了麻烦。

In MyCollectionViewCell.swift

import UIKit
import CorePlot

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

In 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:]: unrecognized selector sent to instance 0x7f8a9aa20240

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x7f8a9aa20240'

最佳答案

您需要将类名 CPTGraphHostingView 设置为 corePlot

@IBOutlet weak var corePlot: CPTGraphHostingView!

在 IB 中的 xib 文件/单元格原型(prototype)中,此处 UIView 崩溃

[UIView setHostedGraph:]

意味着你没有分配它

关于ios - UICollectionViewCell 中的 Core-Plot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52213562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com