In WWDC20 was introduced PHPicker - https://developer.apple.com/documentation/photokit/phpickerviewcontroller, the replacement for UIImagePickerController.
I have a wrapper class witch handles all the configuration and presentation of image picker controller, now I'm replacing the implementation to support iOS14.
Even if I set the delegate to be self I get the error:
[Picker] PHPickerViewControllerDelegate doesn't respond to picker:didFinishPicking:
I think it checks on the parent view controller, that indeed it's not implementing the delegate methods but the wrapper does.
Here is my example code:
import Foundation
import PhotosUI
class myPicker: PHPickerViewControllerDelegate{
		
		func openFrom(parent:UIViewController!) {
				var config:PHPickerConfiguration! = PHPickerConfiguration()
				config.selectionLimit = 1
				config.filter = nil
				
				let pickerViewController:PHPickerViewController! = PHPickerViewController(configuration:config)
				pickerViewController.delegate = self //<
				parent.present(pickerViewController, animated:true, completion:nil)
				
		}
		
		func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
				
				picker.dismiss(animated: true, completion:nil)
				
				for result:PHPickerResult in results {
						let itemProvider:NSItemProvider = result.itemProvider
						print(itemProvider)
				}
// ...do something with images...
		}
}
Using it...
override func viewDidAppear(_ animated: Bool) {
				super.viewDidAppear(animated)
				
				let mypicker = myPicker()
				mypicker.openFrom(parent: self)
		}
What do you suggest?
Post
Replies
Boosts
Views
Activity
I'm converting my collection view to new iOS13 UICollectionViewDiffableDataSource... so I need to update cell information on demand.Here is my code:let snap = self.diffDataSouce.snapshot snap?.reloadItems(withIdentifiers: [itemToUpdate]) //reload cell infoself.diffDataSouce.apply(snap, animatingDifferences: true)But I get Invalid parameter not satisfying: indexPath || ignoreInvalidItems ...why? My current
snap contains
itemToUpdate and also my array of models...
I think it's because snap.indexOfItemIdentifier(itemToUpdate) returns not found (NSNotFound)...but that's should be impossible according data model.
Have you some hints?