         closeButton.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
         containerView.addSubview(closeButton)
 
-        if imagePickerAdapter != nil {
-            let pickerButtonWidth: CGFloat = 114
-            pickerButton = UIButton(frame: CGRect(x: view.bounds.width - pickerButtonWidth - buttonMargin, y: buttonMargin, width: pickerButtonWidth, height: 38))
-            pickerButton.setTitle(NSLocalizedString("Photos", comment: "Select from Photos buttont itle"), for: UIControlState())
-            pickerButton.setImage(UIImage(named: "PhotosIcon"), for: UIControlState())
-            pickerButton.addTarget(self, action: #selector(presentImagePickerTapped(_:)), for: .touchUpInside)
-            pickerButton.titleLabel?.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.footnote)
-            pickerButton.autoresizingMask = [.flexibleTopMargin]
-            pickerButton.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
-            roundifyButton(pickerButton)
-            view.addSubview(pickerButton)
-        }
+        updateImagePickerButton()
 
         previewView.alpha = 0.0
         captureManager.prepare { error in


    fileprivate func updateWidgetsToOrientation() {
        var flashPosition = flashButton.frame.origin
        var pickerPosition = pickerButton.frame.origin
        if orientation == .landscapeLeft || orientation == .landscapeRight {
            flashPosition = CGPoint(x: buttonMargin - (buttonMargin / 3), y: buttonMargin)
            pickerPosition = CGPoint(x: view.bounds.width - (pickerButton.bounds.size.width / 2 - buttonMargin), y: buttonMargin)
        } else if orientation == .portrait || orientation == .portraitUpsideDown {
            pickerPosition = CGPoint(x: view.bounds.width - (pickerButton.bounds.size.width + buttonMargin), y: buttonMargin)
            flashPosition = CGPoint(x: buttonMargin, y: buttonMargin)
        }
        let animations = {
            self.pickerButton.rotateToCurrentDeviceOrientation()
            self.pickerButton.frame.origin = pickerPosition
            self.flashButton.rotateToCurrentDeviceOrientation()
            self.flashButton.frame.origin = flashPosition
            self.closeButton.rotateToCurrentDeviceOrientation()

            case .landscapeLeft, .landscapeRight, .portrait, .portraitUpsideDown:
                self.orientation = UIDevice.current.orientation
                self.updateWidgetsToOrientation()
            }
        }
    }

    private func updateImagePickerButton() {
        if imagePickerAdapter == nil {
            if pickerButton != nil {
                pickerButton?.removeFromSuperview()
                pickerButton = nil
            }
        } else {
            if pickerButton == nil {
                let pickerButtonWidth: CGFloat = 114
                pickerButton = UIButton(frame: CGRect(x: view.bounds.width - pickerButtonWidth - buttonMargin, y: buttonMargin, width: pickerButtonWidth, height: 38))
                pickerButton!.setTitle(NSLocalizedString("Photos", comment: "Select from Photos buttont itle"), for: UIControlState())
                pickerButton!.setImage(UIImage(named: "PhotosIcon"), for: UIControlState())
                pickerButton!.addTarget(self, action: #selector(presentImagePickerTapped(_:)), for: .touchUpInside)
                pickerButton!.titleLabel?.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.footnote)
                pickerButton!.autoresizingMask = [.flexibleTopMargin]
                pickerButton!.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
                roundifyButton(pickerButton!)
                view.addSubview(pickerButton!)
            }
        }
    }
