 
     private func makeAddAccountAlertController() -> UIAlertController {
         let title = "Add Account"
-        let message = "Add an account by scanning a QR code or enter a secret manually."
+        let message = "Add an account by scanning a QR code, importing a QR image, or entering a secret manually."
         let alertController = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
 
         let scanQRCode = UIAlertAction(title: "Scan QR Code", style: .default) { [unowned self] _ in
             self.performSegue(withIdentifier: "ScanSegue", sender: self)
         }
+        
+        let importQRCode = UIAlertAction(title: "Import QR Image", style: .default) { [unowned self] _ in
+            self.qrImporter.allowsEditing = false
+            self.qrImporter.sourceType = .photoLibrary
+                
+            self.present(self.qrImporter, animated: true, completion: nil)
+        }
 
         let enterManually = UIAlertAction(title: "Enter Manually", style: .default) { [unowned self] _ in
             self.performSegue(withIdentifier: "EnterManuallySegue", sender: self)

        let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

        alertController.addAction(scanQRCode)
        alertController.addAction(enterManually)
        alertController.addAction(cancel)

        return alertController
    }

    private func persistAccountOrder() {
        let sortedPersistentRefs = accounts.map { $0.persistentRef! }
        UserDefaults.standard.set(sortedPersistentRefs, forKey: accountOrderKey)


private let accountOrderKey = "persistentRefs"

class AccountsViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet weak var emptyView: UIView!

    private let keychain = Keychain()
    private var accounts = [Account]()
    private let qrImporter = UIImagePickerController()

    private lazy var searchController = makeSearchController()
    private lazy var addAccountAlertController = makeAddAccountAlertController()

