I'm creating a music app and I'm using an UISlider for the music volume control. the problem is when I press the volume button on the iPhone / iPad UISlider does not change or move. I've been looking for where to get no referrals.
This is the code I use:
override func viewDidLoad() {
        super.viewDidLoad()
        
        DispatchQueue.main.async {
            self.slider.setValue(AVAudioSession.sharedInstance().outputVolume, animated: true)
        }
}
@IBAction func volumeControlSlider(_ sender: UISlider) {
        slider = (MPVolumeView().subviews.filter { NSStringFromClass($0.classForCoder) == "MPVolumeSlider" }.first as! UISlider)
        slider.setValue(sender.value, animated: false)
    }