Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showsRouteButton from MPVolumeView is deprecated

Since iOS 13, showsRouteButton from MPVolumeView has been deprecated

let vv = MPVolumeView()
vv.showsRouteButton = false

Warning is :

'showsRouteButton' was deprecated in iOS 13.0: Use AVRoutePickerView instead.

Apple is telling me to use AVRoutePickerView for routing, which makes no sense as in my case I do not want to use any routing stuff, I only want to hide it. It seems there's no more not deprecated way to do this.

If it's deprecated it should be hidden by default else apple should allow us to hide it...

Am I right to say it's an apple API error ?

like image 627
batsansierra Avatar asked Feb 19 '20 11:02

batsansierra


1 Answers

For now just to remove the warning and the default route button I used this immediately after initializing the MPVolumeView.

    if volumeView.value(forKey: #keyPath(MPVolumeView.showsRouteButton)) as? Bool == true {
        volumeView.setValue(false, forKey: #keyPath(MPVolumeView.showsRouteButton))
    }

I check via key value paths if the value of showsRouteButton is true and sets it to false if it is.

like image 154
spasbil Avatar answered Nov 17 '22 22:11

spasbil