Post

Replies

Boosts

Views

Activity

PHPicker delegate error: PHPickerViewControllerDelegate doesn't respond to picker:didFinishPicking
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{ &#9;&#9; &#9;&#9;func openFrom(parent:UIViewController!) { &#9;&#9;&#9;&#9;var config:PHPickerConfiguration! = PHPickerConfiguration() &#9;&#9;&#9;&#9;config.selectionLimit = 1 &#9;&#9;&#9;&#9;config.filter = nil &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;let pickerViewController:PHPickerViewController! = PHPickerViewController(configuration:config) &#9;&#9;&#9;&#9;pickerViewController.delegate = self //< &#9;&#9;&#9;&#9;parent.present(pickerViewController, animated:true, completion:nil) &#9;&#9;&#9;&#9; &#9;&#9;} &#9;&#9; &#9;&#9;func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;picker.dismiss(animated: true, completion:nil) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;for result:PHPickerResult in results { &#9;&#9;&#9;&#9;&#9;&#9;let itemProvider:NSItemProvider = result.itemProvider &#9;&#9;&#9;&#9;&#9;&#9;print(itemProvider) &#9;&#9;&#9;&#9;} // ...do something with images... &#9;&#9;} } Using it... override func viewDidAppear(_ animated: Bool) { &#9;&#9;&#9;&#9;super.viewDidAppear(animated) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;let mypicker = myPicker() &#9;&#9;&#9;&#9;mypicker.openFrom(parent: self) &#9;&#9;} What do you suggest?
2
0
2.7k
Jul ’20
Invalid parameter not satisfying: indexPath || ignoreInvalidItems
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?
2
1
2.7k
Nov ’19