Skip to content

Class to handle events produced by volume buttons in a safe and easy way

Notifications You must be signed in to change notification settings

juliomb/VolumeButtonsListener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

VolumeButtonsListener

With this little class, you would be able to listen and handle events produced by the volume buttons.

I am aware that internally, this is a 'hackish' approach, but I tried to find better solutions and I couldn't. Please, if you discover a proper way to do it, let me know =)


Instructions

Call the following function only once, for example in the didFinishLaunchingWithOptions, not to show the HUD when buttons are pressed.

VolumeButtonsListener.hideVolumeHUD()

Start listening, (f.e: viewWillAppear, UIApplicationDidBecomeActive):

VolumeButtonsListener.listen(){ 
	// Do your stuff here
}

And finally, when you are done (f.e: viewWillDisappear, UIApplicationDidEnterBackground).

VolumeButtonsListener.stopListen()

Please, feel free to suggest improvements!

Thanks Henk for your necessary help.

About

Class to handle events produced by volume buttons in a safe and easy way

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages