我研究了有关App演示的IOS个人数据保护的一些主题。我可以到达文档目录并将所有文件从App上传到服务器(或者可以收集所有联系人列表)。这可以在照相馆吗?
答案 0 :(得分:1)
是的,你可以这样做,用照片从照片库中提取照片。
以下是示例:
import Photos
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
//Array of PHAsset type for storing photos
var images = [PHAsset]()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
getImages()
// Do any additional setup after loading the view, typically from a nib.
}
func getImages() {
let assets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
assets.enumerateObjects({ (object, count, stop) in
// self.cameraAssets.add(object)
self.images.append(object)
})
//In order to get latest image first, we just reverse the array
self.images.reverse()
self.tableView.reloadData()
}
}
extension ViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
let imageAsset = self.images[indexPath.row]
PHImageManager.default().requestImage(for: imageAsset, targetSize: CGSize(width: 120.0, height: 120.0), contentMode: .aspectFill, options: nil) { (result, _) in
cell?.imageView?.image = result
}
return cell!
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return images.count
}
}