iPhone SDK - How to disable the volume indicator view if the hardware buttons are pressed?

后端 未结 3 1595
猫巷女王i
猫巷女王i 2020-12-30 15:43

Is there a way to prevent the volume indicator view form showing if you press the volume up/down hardware buttons?

It\'s needed for a demo app only. So the method do

3条回答
  •  灰色年华
    2020-12-30 16:20

    IIRC, the presence of a MPVolumeView inhibits the display of the volume indicator overlay. Try sticking it the relevant view and seeing if this is the case.

    Then you can try various tricks to make it effectively invisible:

    • Make it hidden (or make a superview hidden).
    • Set its alpha (or the alpha of a superview) to 0, or 0.01, or so.
    • Move it off-screen
    • Move it almost off-screen (e.g. so only the top-left pixel is on screen)
    • Stick it under another view.
    • Stick it in a subview with clipsToBounds=ON, and move it outside those bounds
    • Set volumeView.layer.mask to a new (thus fully-transparent) CALayer. Set volumeView.userInteractionEnabled = NO.

    All of these are theoretically detectable by MPVolumeView, but I suspect some of them will work.

提交回复
热议问题