Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2.0 Call Button Capture Photo/Video #684

Closed
Anoeta opened this issue May 5, 2024 · 8 comments
Closed

4.2.0 Call Button Capture Photo/Video #684

Anoeta opened this issue May 5, 2024 · 8 comments

Comments

@Anoeta
Copy link

Anoeta commented May 5, 2024

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
Copy link
Owner

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

@Anoeta
Copy link
Author

Anoeta commented May 6, 2024

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,

@SilenceLove
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

Anoeta commented May 6, 2024

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
Copy link
Owner

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

@Anoeta
Copy link
Author

Anoeta commented May 7, 2024

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
Copy link
Owner

Of course, use EditorViewController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants