我有一个关于Core Plot Realtime的奇怪问题。我有一个UIButton,它可以启动和停止更新绘图数据的定时器。我保留了前几个点的历史记录,并且只显示了最后150个值。这一切都很好用。现在,当我根据计时器打开并将其设置为关闭来更改UIButton的文本时,绘图将重置为其初始的前150个值。当我重新启动计时器时,它从数据末尾停止的地方重新开始计时。代码如下所示:
@IBOutlet weak var pause: UIButton!
@IBAction func pausePlay() {
if isPaused {
startGraphUpDates()
isPaused = false
pause.setTitle("⏸", for: .normal)
} else {
stopGraphUpDates()
isPaused = true
pause.setTitle("▶️", for: .normal) // This is the statement that seems to cause the problem.
}
}如果您有任何想法,我们将不胜感激
发布于 2020-05-12 21:36:21
这是一个简单的解决方案。我在以下位置初始化绘图:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
initPlot()
}我应该在下面的代码中初始化绘图:
override func viewDidLoad() {
super.viewDidLoad()
initPlot()
}https://stackoverflow.com/questions/61714476
复制相似问题