简体   繁体   English

如何通过调高音量按钮拍照并在iOS中显示任何弹出窗口?

[英]How to take picture by the volume up button with showing any popup in iOS?

I'm using JPSVolumeButtonHandler, but in this I got the volume up button action. 我正在使用JPSVolumeButtonHandler,但是在此操作中,我得到了“调高音量”按钮的动作。 But in this ringer and volume button popup is showing. 但是在此铃声和音量按钮中会显示弹出窗口。 How to take picture? 怎么拍照?

From iOS 8 you can add an observer to the notification 在iOS 8中,您可以将观察者添加到通知中

_UIApplicationVolumeUpButtonDownNotification

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

If you are using UIImagePickerController , you able to capture the event and use it to call TakePicture with a custom view. 如果您使用的是UIImagePickerController ,则可以捕获事件并使用它以自定义视图调用TakePicture

On top of that, UIImagePickerController ensures that pressing volume up won't change the volume. 最重要的是, UIImagePickerController确保提高音量不会改变音量。

Or you can use thirdparty library like, JPSVolumeButtonHandler . 或者,您可以使用第三方库,例如JPSVolumeButtonHandler

Update : 更新:

you can do something like, 你可以做类似的事情,

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

Don't forget to @import MediaPlayer; 不要忘记@import MediaPlayer;

refer this Apple documentation for more detail. 有关更多详细信息,请参阅此Apple文档

Hope this will help :) 希望这会有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM