2016-04-27 24 views

回答

1

從iOS 8的就可以。如果你正在使用UIImagePickerController觀察者添加到通知

_UIApplicationVolumeUpButtonDownNotification

[[NSNotificationCenter defaultCenter] addObserver:self 
            selector:@selector(volumeChanged:) 
            name:@"_UIApplicationVolumeUpButtonDownNotification" 
            object:nil]; 

,你能捕捉到事件並使用它來調用TakePicture與自定義視圖。

最重要的是,UIImagePickerController確保按下音量不會改變音量。

或者您可以使用第三方庫,如JPSVolumeButtonHandler

更新:

,你可以這樣做,

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame: CGRectZero]; 
[self.view addSubview: volumeView]; 

不要忘記@import MediaPlayer;

請參閱本Apple documentation瞭解更多詳情。

希望這會幫助:)

+0

我不想彈出卷。我說我得到了行動,但彈出窗口也出現了。 –

+0

檢查我的更新在anser如果它可以幫助:) – Lion

相關問題