简体   繁体   中英

iOS switch camera with UIImagePickerController custom camera overlay view

是否有一种简单的方法,可以使用UIImagePickerController摄像机叠加视图上的自定义按钮从前摄像机切换到后摄像机,而无需使用AVCapture框架?

Hook the overlay view to the class in which you're writing the UIImagePickerController's code by selecting the File's Owner box in the overlay view, going to the Identity Inspector, and adding the class name that the overlay is attaching to. Then, hook the button from the overlay view to the new class with an IBAction. In the IBAction method, you can use the cameraDevice options from the UIImagePickerController class to switch camera views.

- (IBAction)switchToFrontCamera:(id)sender {

    self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;


}

- (IBAction)switchToBackCamera:(id)sender {

    self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;


}

Hope that answers your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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