HXPhotoPicker icon indicating copy to clipboard operation
HXPhotoPicker copied to clipboard

4.2.0 Call Button Capture Photo/Video

Open Anoeta opened this issue 2 months ago • 8 comments

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!

Anoeta avatar May 05 '24 17:05 Anoeta

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

SilenceLove avatar May 06 '24 03:05 SilenceLove

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
    }
  }
  • The result is that, the camera is launching correctly but the swipe gesture (going to A and C) doesn't work anymore.

  • And when I try another option (just put CameraController.capture on a button in my classical VC B), then when I press the button from VC B with CameraController.capture, it calls a new VC from HXPhotoPicker and the swipe gesture doesnt work anymore

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,

Anoeta avatar May 06 '24 07:05 Anoeta

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 avatar May 06 '24 10:05 SilenceLove

You can try this

import HXPhotoPicker
class B: CameraViewController {

}

var config = CameraConfiguration()
let vc = B(config: config, type: .all)
vc.setFlashMode(.auto)
vc.didSwitchCameraClick()

SilenceLove avatar May 06 '24 10:05 SilenceLove

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()
     }     
                                            
}

Anoeta avatar May 06 '24 15:05 Anoeta

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

SilenceLove avatar May 07 '24 02:05 SilenceLove

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 👍

  • Once I get my UIImage from a photo, or a media, can I use your edit features calling a method ? 🙏

sample_graph_photo_editor_filter I would love it

Thanks

Anoeta avatar May 07 '24 05:05 Anoeta

Of course, use EditorViewController

SilenceLove avatar May 07 '24 08:05 SilenceLove