I am using an applicationMusicPlayer and when i try to change the volume appear the visual notification, as shown in the picture. Here the code I am using:
[MPMusicPlayerController applicationMusicPlayer] setVolume:newVolune];
Anyone knows how to hide this notification?
For me, on iOS 7, none of above solutions worked. Here is how I did it:
That is, simply set MPVolumeView's frame to an off-screen location such as (-100,-100).
I don't know where the docs says so, but if you add a
MPVolumeView
view to your app the system volume overlay goes away. Even if it is not visible:You can use the hardware volume buttons, the
setVolume
method or directly interact with the control (if visible) that the overlay doesn't show up.Swift 3
You can hide the System MPVolumeView using
I had success with this in iOS 6. Although it wouldn't perform well. It caused quite a bit of lag when sliding the thumbImage. I did have to take out the last 2 lines of code in order for this to work.
For iOS6 I had to set an image with alpha 0 and non-zero size to the
MPVolumeView
's image fields in order to get the default volume change notification to disappear.This made the
MPVolumeView
be "visible" on the screen, but invisible to the user.I encountered the same issue recently. Instead of adding the MPVolumeView to current view controller's view, I add it to the application's window once at the start of the app:
This works in both iOS 7 and 8.