CameraViewController

public class CameraViewController: UIViewController, UIPopoverPresentationControllerDelegate

Open camera to take photo. This view controller will include user guide info button, flash button and reverse camera button

  • title for info popover. Default to How to Use

    Declaration

    Swift

    public var infoTitle : String = "How to Use"
  • Default instruction on how to take photo

    Declaration

    Swift

    public var infoTxt : String = "Snap a photo of an item you'd like to find, and we'll search our store to find a match or something very similar."
  • Tips for using camera button

    Declaration

    Swift

    public var infoCameraTxt : String = "Photograph the item straight-on in bright lighting for the best search results."
  • Tips for using flash button

    Declaration

    Swift

    public var infoFlashTxt : String = "Use the flash if there isn't enough light"
  • show/hide Power by ViSenze logo

    Declaration

    Swift

    public var showPowerByViSenze : Bool = true
  • Camera view

    Declaration

    Swift

    public let cameraView : CameraView =
  • camera button for taking photo

    Declaration

    Swift

    public let cameraButton : UIButton =
  • close camera button. Default to back arrow icon

    Declaration

    Swift

    public let closeButton : UIButton =
  • Info button. For showing user guide

    Declaration

    Swift

    public let infoButton : UIButton =
  • Power by ViSenze

    Declaration

    Swift

    public let powerView : UIImageView =
  • swap/reverse front and back camera button

    Declaration

    Swift

    public let swapButton : UIButton =
  • select photo from library button

    Declaration

    Swift

    public let libraryButton : UIButton =
  • turn on/off flash button

    Declaration

    Swift

    public let flashButton : UIButton =
  • Constructor

    • Parameters:
      • croppingEnabled: enable/disable cropping after taking photo
      • allowsLibraryAccess: whether to allow user select image from photo library
      • completion: callback after taking photo / selecting photo from library

    Declaration

    Swift

    public init(croppingEnabled: Bool, allowsLibraryAccess: Bool = true, completion: @escaping CameraViewCompletion)

    Parameters

    croppingEnabled

    enable/disable cropping after taking photo

    allowsLibraryAccess

    whether to allow user select image from photo library

    completion

    callback after taking photo / selecting photo from library

  • Undocumented

    Declaration

    Swift

    public class CameraViewController: UIViewController, UIPopoverPresentationControllerDelegate
  • Undocumented

    Declaration

    Swift

    public class CameraViewController: UIViewController, UIPopoverPresentationControllerDelegate
  • Undocumented

    Declaration

    Swift

    public class CameraViewController: UIViewController, UIPopoverPresentationControllerDelegate
  • Configure the background of the superview to black and add the views on this superview. Then, request the update of constraints for this superview.

    Declaration

    Swift

    public override func loadView()
  • Setup the constraints when the app is starting or rotating the screen. To avoid the override/conflict of stable constraint, these stable constraint are one time configurable. Any other dynamic constraint are configurable when the device is rotating, based on the device orientation.

    Declaration

    Swift

    override public func updateViewConstraints()
  • Add observer to check when the camera has started, enable the volume buttons to take the picture, configure the actions of the buttons on the screen, check the permissions of access of the camera and the photo library. Configure the camera focus when the application start, to avoid any bluried image.

    Declaration

    Swift

    public override func viewDidLoad()
  • Start the session of the camera.

    Declaration

    Swift

    public override func viewWillAppear(_ animated: Bool)
  • Enable the button to take the picture when the camera is ready.

    Declaration

    Swift

    public override func viewDidAppear(_ animated: Bool)
  • Update constraints during rotation

    Declaration

    Swift

    override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
  • important - this is needed so that a popover (info guide text) will be shown instead of fullscreen for ios 8.3+

    Declaration

    Swift

    public func adaptivePresentationStyle(for controller: UIPresentationController,
                                              traitCollection: UITraitCollection) -> UIModalPresentationStyle
  • return .none to display as popover (ios 8.0 - 8.2)

    Declaration

    Swift

    public func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle