SilenceLove / HXPhotoPicker

图片/视频选择器 - 支持LivePhoto、GIF图片选择、3DTouch预览、在线下载iCloud上的资源、编辑图片/视频、浏览网络图片 功能 Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function
https://github.com/SilenceLove/HXPhotoPicker
MIT License
3.1k stars 663 forks source link

4.2.0 Call Button Capture Photo/Video #684

Closed Anoeta closed 6 months ago

Anoeta commented 6 months ago

Hello @SilenceLove , Wonderfull job with HXPhotoPicker, you got my support !

I would like to add your Camera button + flip button on my UIViewController (because I have already some labels/other button on it). Is it possible juste to add the button Capture Photo (with longtap gesture to capture video) + the flip button to reverse Camera ?

I already read issue559 but this call the View with it, and I just want the button.

Thanks and again big fan of your job!

SilenceLove commented 6 months ago

Thanks for your support. I don't quite understand your needs. Are you using CameraController?

Anoeta commented 6 months ago

Hello @SilenceLove

To be more precise 😃 :

I have 3 VC (A B C) with swipe view with this setup I would like to put your button (Camera and flip) in the VC B and have the swipe view working.

On my VC B (the middle one) , I tested (taken from your response issue 559) :

 override func viewDidAppear(_ animated: Bool) {
        var config = CameraConfiguration()
        config.modalPresentationStyle = .fullScreen

        Photo.capture(config, type: .all) { result, location in
            switch result {
            case .image(let image):
                print(image)
            case .video(let url):
               print(url)
            }
        }
    }

So to be complete : My VC B with your fantastic stuff :

import HXPhotoPicker
class B: UIViewController{

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func viewDidAppear(_ animated: Bool) {
        var config = CameraConfiguration()
        config.modalPresentationStyle = .fullScreen

        Photo.capture(config, type: .all) { result, location in
            switch result {
            case .image(let image):
               print(image)
            case .video(let url):
               print(url)
            }
        }
    }
}

and my Appdelegate

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let left = storyboard.instantiateViewController(withIdentifier: "left")
        let middle = storyboard.instantiateViewController(withIdentifier: "middle")
        let right = storyboard.instantiateViewController(withIdentifier: "right")
        let top = storyboard.instantiateViewController(withIdentifier: "top")
        let bottom = storyboard.instantiateViewController(withIdentifier: "bottom")

 let snapContainer = SnapContainerViewController.containerViewWith(left as! A, middleVC: middle as! B, rightVC: right as! C, topVC: top as! D)
        self.window?.rootViewController = snapContainer
        self.window?.makeKeyAndVisible()
        return true
    }
  }

That's why I wanted to take only your camera button and the flip button to put on my B controller and have the swipe setup working I don't know how to make it . Hope it is more understandable 😄

Thanks again,

SilenceLove commented 6 months ago

I seem to understand your needs, but HXPhotoPicker.Camera does not support the use of separate controls. CameraController is a navigation controller, and a navigation bar is used internally. Cannot be embedded into SnapContainerViewController. You need to use present to pop up the camera

SilenceLove commented 6 months ago

You can try this

import HXPhotoPicker
class B: CameraViewController {

}

var config = CameraConfiguration()
let vc = B(config: config, type: .all)
vc.setFlashMode(.auto)
vc.didSwitchCameraClick()
Anoeta commented 6 months ago

I tried and I got an error on the class CameraViewController

Error : HXPhotoPicker/CameraViewController.swift:341: Fatal error: init(coder:) has not been implemented

 required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

My code :

import HXPhotoPicker
class B: CameraViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func viewDidAppear(_ animated: Bool) {
     var config = CameraConfiguration()
     let vc = B(config: config, type: .all)
     vc.setFlashMode(.auto)
     vc.didSwitchCameraClick()
     }     

}
SilenceLove commented 6 months ago

I think what you may need is this kind of library which can support your needs, custom camera NextLevel

Anoeta commented 6 months ago

I think what you may need is this kind of library which can support your needs, custom camera NextLevel

Ok, I'll check this out 👍

sample_graph_photo_editor_filter I would love it

Thanks

SilenceLove commented 6 months ago

Of course, use EditorViewController