Posts

Post not yet marked as solved
2 Replies
2.5k Views
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?
Posted
by fabio208.
Last updated
.
Post marked as solved
2 Replies
2.2k Views
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?
Posted
by fabio208.
Last updated
.
Post not yet marked as solved
0 Replies
599 Views
I created a UIDocumentPickerViewController and picked my folder on USB drive, after listing files with an enumerator, how can i read the contents?Are you able to read the contents of a file?Here is my sample code:@IBAction func readFiles(){ // Reading the Content of a Picked Folder let shouldStopAccessing = pickedFolderURL.startAccessingSecurityScopedResource() defer { if shouldStopAccessing { pickedFolderURL.stopAccessingSecurityScopedResource() } } var coordinatedError:NSError? NSFileCoordinator().coordinate(readingItemAt: pickedFolderURL, error: &amp;coordinatedError) { (folderURL) in let keys : [URLResourceKey] = [.nameKey, .isDirectoryKey] let fileList = FileManager.default.enumerator(at: pickedFolderURL, includingPropertiesForKeys: keys)! logString = "" for case let file as URL in fileList { let newFile = file.path.replacingOccurrences(of: pickedFolderURL.path, with: "") if(newFile.hasPrefix("/.") == false){ //exclude hidden print(file) logString += "\n\(file)" if (file.pathExtension == "mp4"){ self.pickedVideoURL = file } if (file.pathExtension == "txt"){ self.pickedTextURL = file } } } self.logTextView.text = logString } }now i want to read the contents of the txt file... how?Have you sample project?
Posted
by fabio208.
Last updated
.
Post not yet marked as solved
4 Replies
1.4k Views
Hello,i'm trying to implement ios13 darkmode within multi scene application.Unfortunately when i dismiss a scene dragging it over the screen edge the method traitCollectionDidChange is called several times with always different values, causing my UI to flicker between dark and light mode.What's wrong?Here is my implementationfunc traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) print("THEME instance: \(self)") let currentTraitCollection = self.traitCollection var hasUserInterfaceStyleChanged = false hasUserInterfaceStyleChanged = previousTraitCollection.hasDifferentColorAppearanceCompared(to: currentTraitCollection) print("THEME hasUserInterfaceStyleChanged = \(hasUserInterfaceStyleChanged ? "YES" : "NO")") if hasUserInterfaceStyleChanged { let userInterfaceStyle = currentTraitCollection.userInterfaceStyle // Either .unspecified, .light, or .dark switch userInterfaceStyle { case .unspecified: print("THEME UIUserInterfaceStyleUnspecified") case .light: print("THEME UIUserInterfaceStyleLight") case .dark: print("THEME UIUserInterfaceStyleDark") } } else { print("THEME NOT CHANGED") } }Here is the logged statements in consoleWhene new scene comes in...THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = YES THEME UIUserInterfaceStyleLightWhene added scene goes away...THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = YES THEME UIUserInterfaceStyleDark THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = YES THEME UIUserInterfaceStyleLight THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = NO THEME NOT CHANGED THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = YES THEME UIUserInterfaceStyleDark THEME instance: &lt;MainControllerViewController: 0x117e55910&gt; THEME hasUserInterfaceStyleChanged = YES THEME UIUserInterfaceStyleLightin meantime i have no changed to dark mode (always light)...so i expect just THEME NOT CHANGED.
Posted
by fabio208.
Last updated
.
Post not yet marked as solved
0 Replies
883 Views
I'm updating my current UITableview to diffable datasource provided by iOS 13 UITableViewDiffableDataSource.I have an array with a custom object (implementing isEqual: and hash: methods).On load everythiong works, but when a try to add a new item and call again updateTableViewAnimated:, I get an exception.*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Inconsistent associations for moves'What does it mean? How can I solve?
Posted
by fabio208.
Last updated
.