gpt4 book ai didi

ios - Swift NSPhotoLibraryUsageDescription 键不读

转载 作者:搜寻专家 更新时间:2023-11-01 07:15:06 27 4
gpt4 key购买 nike

我已将 key 和字符串消息添加到 .plist,但由于某种原因,我的应用程序不断崩溃,我不知道为什么。我从 swift 添加到 .plist 文件,我也尝试将它手动添加到代码中。当我运行该应用程序时它不工作,当我到达那个点时它仍然崩溃。

https://useyourloaf.com/assets/images/2016/2016-07-03-001.png

错误信息:

This app has crashed because it attempted to access privacy-sensitive data 
without a usage description. The app's Info.plist must contain an
NSPhotoLibraryUsageDescription key with a
string value explaining to the user how the app uses this data.




import UIKit
import Firebase
import FirebaseStorage
import KeychainSwift


class UserProfile: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

//Username UI Label
@IBOutlet weak var changeImageButton: UIButton!


@IBOutlet weak var usernameLabel: UILabel!
@IBOutlet weak var userProfileImage: UIImageView!

var ref: FIRDatabaseReference!
var storage: FIRStorageReference!

override func viewDidLoad() {
super.viewDidLoad()

ref = FIRDatabase.database().reference()
storage = FIRStorage.storage().reference()

//Make Porfile Image Cirlce
userProfileImage.layer.cornerRadius = userProfileImage.frame.size.width/2
userProfileImage.clipsToBounds = true

let userID = FIRAuth.auth()?.currentUser?.uid

ref.child("Users").child(userID!).observeSingleEvent(of: .value, with: {(snapshot) in

let snapDict = snapshot.value as? NSDictionary

let username = snapDict?["Username"] as? String ?? "" //Get Username


//print("Username: " + username)

self.usernameLabel.text = username //Label set to UserName


})

}//View Did load


@IBAction func choosePicture(_ sender: AnyObject) {

let pickerController = UIImagePickerController()
pickerController.allowsEditing = true

let alertController = UIAlertController(title: "Add Picture", message: "Choose From", preferredStyle: .actionSheet)

let cameraAction = UIAlertAction(title: "Camera", style: .default) { (action) in
pickerController.sourceType = .camera
self.present(pickerController, animated: true, completion: nil)

}


let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .default) { (action) in
pickerController.sourceType = .photoLibrary
self.present(pickerController, animated: true, completion: nil)
}

let savedPhotosAction = UIAlertAction(title: "Saved Photos Album", style: .default) { (action) in
pickerController.sourceType = .savedPhotosAlbum
self.present(pickerController, animated: true, completion: nil)
}


let cancelAction = UIAlertAction(title: "Cancel", style: .destructive, handler: nil)
alertController.addAction(cameraAction)
alertController.addAction(photoLibraryAction)
alertController.addAction(savedPhotosAction)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)


}//END CHOOSE PICTURE

func imagePickerControllerDidCancel(_ picker: UIImagePickerController, didFinishPackageImage image: UIImage, editingInfo: [String : AnyObject]?) {

self.dismiss(animated: true, completion: nil)
self.userProfileImage.image = image
}


func updateProfilePicture() {

//Assign current user ID
let userID = FIRAuth.auth()?.currentUser?.uid

//Create an access point for the Firebase Storage
let storageItem = storage.child("profile_images").child(userID!)

guard let image = userProfileImage.image else {return}

if let newImage = UIImagePNGRepresentation(image) {

//upload to Firebase
storageItem.put(newImage, metadata: nil, completion: { (metadata, error) in
if error != nil{
print(error!)
return

}

storageItem.downloadURL(completion: { (url, error) in if error != nil{
print(error!)
return
}
})
})

}


}


//UI Button: Sign Out the User
@IBAction func SignOut(_ sender: UIButton) {

let firebaseAuth = FIRAuth.auth()
do {
try firebaseAuth?.signOut()
} catch let signOutError as NSError {
print ("Error signing out: %@", signOutError)
}
//KeychainSwift().delete("uid")
DataService().keyChain.delete("uid")
dismiss(animated: true , completion: nil)
}








}//End UserProfile Class

最佳答案

你用错了。应该是“隐私照片库使用”

关于ios - Swift NSPhotoLibraryUsageDescription 键不读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42517461/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com