Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Puedo acceder a la biblioteca de fotos de iOS sin solicitar permiso

Estoy tratando de acceder a la biblioteca de fotos de una nueva aplicación que estoy escribiendo. Tengo una hoja de acción que le permite al usuario elegir entre su cámara y su biblioteca de fotos. Al abrir la cámara pide permiso al usuario pero al abrir la fototeca no. A pesar de esto, aún lleva al usuario a su biblioteca de fotos. Lo mencioné específicamente en mi info.plist, pero todavía no hay diferencia. ¿Alguna ayuda? Mi código:

 @IBAction func allowAccessToPhotos(_ sender: Any) { let imagePickerController = UIImagePickerController() imagePickerController.delegate = self let actionSheet = UIAlertController(title: "Photo Source", message: "Choose a Source", preferredStyle: .actionSheet) actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: { (action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary self.present(imagePickerController, animated: true, completion: nil) })) actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: { (action:UIAlertAction) in imagePickerController.sourceType = .camera self.present(imagePickerController, animated: true, completion: nil) })) actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) self.present(actionSheet, animated: true, completion: nil) }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Según el comportamiento de UIImagePickerController , nunca da diálogo al usuario para acceder a Photos . UIImagePickerController solo solicita el permiso de la Camera .

Tienes que pedir permission de Photos manualmente al usuario. Al usar el siguiente código, puede solicitar al usuario el permiso de Photos .

 import Photos @IBAction func allowAccessToPhotos(_ sender: Any) { let imagePickerController = UIImagePickerController() imagePickerController.delegate = self let actionSheet = UIAlertController(title: "Photo Source", message: "Choose a Source", preferredStyle: .actionSheet) actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: { (action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus() switch photoAuthorizationStatus { case .authorized: self.present(imagePickerController, animated: true, completion: nil) case .notDetermined: PHPhotoLibrary.requestAuthorization({ (newStatus) in DispatchQueue.main.async { if newStatus == PHAuthorizationStatus.authorized { self.present(imagePickerController, animated: true, completion: nil) }else{ print("User denied") } }}) break case .restricted: print("restricted") break case .denied: print("denied") break }})) actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: { (action:UIAlertAction) in imagePickerController.sourceType = .camera self.present(imagePickerController, animated: true, completion: nil) })) }

Consulte la referencia.

Nota IMPORTANTE:

Si no está solicitando el permiso de Photos al usuario, el equipo de Apple lo rechazará. Depende de tu suerte, a veces el equipo de Apple lo ignora y otras veces rechaza nuestra aplicación.

over 4 years ago · Santiago Trujillo Report

0

Desde iOS 11, UIImagePickerController se ejecuta de forma remota en un proceso separado. Por lo tanto, su aplicación no necesita la autorización de privacidad estándar para el acceso a la biblioteca de Fotos, obtiene acceso de solo lectura solo para cualquier recurso que el usuario elija en ImagePicker.

Para agregar un nuevo activo a la biblioteca de fotos, necesita NSPhotoLibraryAddUsageDescription en su Info.plist - hilo del foro

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!