picker.showsCameraControls = NO;
picker.cameraOverlayView = someView;
由于我将向 showCameraControls 添加一些自定义 View ,那么如何在模式之间切换,就像 iPhone 的 native 应用程序在相机和录制之间切换一样,就像我想在相机和另一个带有按钮的相机之间切换一样,我该怎么做? 救命!
最佳答案
在您的自定义 View 中,您将通过一键设置选择器作为目标,并使用 takePicture 方法。然后,您将有另一个按钮,或开关,或者您想要进入自定义模式的方式,并且您将有一个按钮来开始/停止捕捉。这个按钮应该有 self 作为目标(self 作为您提供选择器的 View Controller )和自定义的toggleSnapping 方法。您还需要将自己设置为图像选择器的代表,以便在拍摄每张照片时收到通知。哦,还有一个 BOOL 实例变量,用于跟踪捕捉当前是否处于事件状态。那么你的toggleSnapping方法可能看起来像这样:
- (void)toggleSnapping
{
isSnapping = !isSnapping; // (this will reverse NO to YES and vice-versa)
[picker takePicture]; // starts taking 1st picture, delegate will take care of rest
if (isSnapping) {
// configure your button to show stop icon
} else {
// configure your button to show start snapping icon
}
}
并且您需要实现选择器的委托(delegate)方法,如果 isSnapping 当前为 YES,您只需启动另一张图片即可:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// save the snapped picture to the camera roll
if (isSnapping) { // if burst mode is on, take another picture
[picker takePicture];
}
}
关于ios - 如何在UIImagePickerController的自定义控件中使用不同模式之间的切换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7020475/