I have a secondary View Controller that uses some haptic feedback. I am triggering the haptic feedback on a scheduled timer that loops every 14 seconds
Timer.scheduledTimer(withTimeInterval: 14, repeats: true) { _ in
self.changeLabel()
}
This timer calls a function that triggers 2 haptic feedback hits
@objc func changeLabel() {
if counter2 == 1 {
//Haptics
let impactGenerator = UIImpactFeedbackGenerator(style: .medium)
impactGenerator.prepare()
impactGenerator.impactOccurred()
Timer.scheduledTimer(withTimeInterval: 7, repeats: false) { _ in
let impactGenerator = UIImpactFeedbackGenerator(style: .medium)
impactGenerator.prepare()
impactGenerator.impactOccurred()}
//Changing Label
self.mainFocusLabel.text = self.foclabel1Text
self.manifestationImg.sd_setImage(with: URL(string: self.imglabel1URL))
self.counter2 = 2
(theres more code but they are all almost identical to this block, the only differences are that it just changes the label to focuslabel2-10 and uses the counter to recognize what's the next label to change.
What is happening which I'm confused about is-- after the view is closed out-- the vibrations (and apparently the timer?) are still going. My phone is vibrating at the same intervals. I haven't seen any code to disable haptic feedback. I would imagine that I can just add that to the other view controller to solve this.