Core Plot Real Time interaction with UIButton .setText

45 Views Asked by At

I have a strange problem with Core Plot Realtime. I have a UIButton that starts and stops a timer that up-dates the plot data. I do keep a history of the previous points and only display the last 150 values. It all works great. Now when I then change the text for the UIButton based on the timer being on and setting it to off, the plot resets to its initial first 150 values. when I restart the timer it picks up where it left off at the end of the data. The code looks like this:

@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.
     }
}

Any thoughts would be appreciated

1

There are 1 best solutions below

0
Michael Jay On

This was a simple fix. I was initializing the plot in:

override func viewDidLayoutSubviews() {
  super.viewDidLayoutSubviews()
  initPlot()
}

I should have initialized the plot in:

override func viewDidLoad() {
  super.viewDidLoad()
  initPlot()
}