PhotoKit

RSS for tag

Work with image and video assets managed by the Photos app, including those from iCloud Photos and Live Photos, using PhotoKit.

Posts under PhotoKit tag

87 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Photos framework and reusable UICollectionViewCell
I have a UICollectionView to display photos from a device's album with the Photos framework. The photos are correctly displayed, but if I scroll fast (like when you tape at the top of the screen to go to the top of the collectionView), I have some photos which are not at the good indexPath. I just need to scroll a bit to put the bad photo out of the screen, and everything go back in place.I clean the cell during prepareForReuse by canceling the current request.I presume it's a problem with the asynchronous request of PHImageManager, but I don't know how to avoid this problem. And I want to keet the asynchronous request to keep the collectionView smooth.Here some code :View Controller extension AlbumDetailViewController : UICollectionViewDataSource { func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1 } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return photoList.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("PhotoCell", forIndexPath: indexPath) as! PhotoCollectionCell cell.setImage(photoList.objectAtIndex(indexPath.row) as! PHAsset) return cell } }Custom CollectionViewCell class PhotoCollectionCell: UICollectionViewCell { @IBOutlet weak var imageView: UIImageView! var requestId: PHImageRequestID! let manager = PHImageManager.defaultManager() override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func prepareForReuse() { self.imageView.image = nil manager.cancelImageRequest(self.requestId) } func setImage(asset: PHAsset) { let option = PHImageRequestOptions() option.resizeMode = .Fast option.deliveryMode = .HighQualityFormat self.requestId = manager.requestImageForAsset(asset, targetSize: CGSize(width: self.frame.size.width * UIScreen.mainScreen().scale, height: self.frame.size.height * UIScreen.mainScreen().scale), contentMode: PHImageContentMode.Default, options: option, resultHandler: {(result, info)->Void in self.imageView.image = result }) } }Thank you
1
0
1.3k
Oct ’23
How to correctly load video selected with PHPickerViewController?
Hello! I am playing around with the PHPickerViewController and so far I was able to get the selected images by loading them into UIImage instances but I don't know how to get the selected video. Below is the relevant implementation of the method: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]): let provider = result.itemProvider guard provider.hasItemConformingToTypeIdentifier(AVFileType.mov.rawValue) else { return } 						provider.loadItem(forTypeIdentifier: AVFileType.mov.rawValue, options: nil) { (fileURL, error) in 								if let error = error { 										print(error) 										return 								} 								guard let videoURL = fileURL as? URL else { return } 								DispatchQueue.main.async { 										let fm = FileManager.default 										let destination = fm.temporaryDirectory.appendingPathComponent("video123.mov") 										try! fm.copyItem(at: videoURL, to: destination) 										let playerVC = AVPlayerViewController() 										playerVC.player = AVPlayer(url: destination) 										self.present(playerVC, animated: true, completion: nil) 								} 						} I get crash trying to copy the item. It says the source file does not exists but the path looks real to me. "The file “3C2BCCBC-4474-491B-90C2-93DF848AADF5.mov” couldn’t be opened because there is no such file." I tried it without copying first and just passing the URL to AVPlayer but nothing would play. I am testing this on a simulator. Thanks for help!
13
0
7.5k
Sep ’23
Could not load some videos
Hello there! I am trying to use PHPickerViewController to load videos, but I got a problem: I could load some videos only not all. I refer to the existing thread - https://developer.apple.com/forums/thread/652695, but dosen't work. This is the code I persent PHPickerViewController var config = PHPickerConfiguration() config.selectionLimit = 1 config.filter = .videos config.preferredAssetRepresentationMode = .current let picker = PHPickerViewController(configuration: config) picker.delegate = self present(picker, animated: true, completion: nil) Below is the relevant implementation of the method: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]): picker.dismiss(animated: true, completion: nil) for result in results {   result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { (url, error) in     if let error = error {       print(error)       return     }     guard let url = url else { return }     let fileName = "\(Date().timeIntervalSince1970).\(url.pathExtension)"     let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName)     try? FileManager.default.copyItem(at: url, to: newUrl)     DispatchQueue.main.async {       self.playVideo(newUrl)     }   } } Before I print error in line 5, Xcode printed 3 lines of error: [AXRuntimeCommon] Unknown client: TestPHPicker [default] [ERROR] Could not create a bookmark: NSError: Cocoa 257 "The file couldn’t be opened because you don’t have permission to view it." } Error copying file type public.movie. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.movie" UserInfo={NSLocalizedDescription=Cannot load representation of type public.movie, NSUnderlyingError=0x283a4a610 {Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x283a48b10 {Error Domain=PHAssetExportRequestErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x283a4a550 {Error Domain=CloudPhotoLibraryErrorDomain Code=82 "Failed to download CPLResourceTypeOriginal" UserInfo=0x28219b300 (not displayed)}}}}}} And I print error in line 5: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.movie" UserInfo={NSLocalizedDescription=Cannot load representation of type public.movie, NSUnderlyingError=0x283a4a610 {Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x283a48b10 {Error Domain=PHAssetExportRequestErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x283a4a550 {Error Domain=CloudPhotoLibraryErrorDomain Code=82 "Failed to download CPLResourceTypeOriginal" UserInfo=0x28219b300 (not displayed)}}}}}} For some videos I can load successfully, and some videos I got error. I don't know why this happened. I am testing this on an iPhone X iOS 14.0(18A373). Xcode 12.0 (12A7209). Thanks for help!
6
0
2.9k
May ’24
PhotoKit - non-system library
Hi, I'm wondering if it is possible to manipulate the "other" Photos library with PhotoKit, not the only System one. PhotoKit documentation only mentioned object of PHPhotoLibrary class, which is "a shared object that manages access and changes to the user’s shared photo library". But the Photos app in macOS allows to create and switch between multiple photo libraries. Thanks.
2
2
715
Sep ’23
iOS 14 Photo caption - how to access in metadata??
I use the following code to parse Photo metadata and this works well. However, I am unable to pull the new iOS 14 "caption" from this metadata (it worked in early iOS 14 betas, but has since stopped working in the GM.) Does anyone know how I can get the caption data from a PHAsset? Thanks! Stephen         let options = PHContentEditingInputRequestOptions()         options.isNetworkAccessAllowed = true         asset.requestContentEditingInput(with: options, completionHandler: {(contentEditingInput, _) -> Void in             if let url = contentEditingInput?.fullSizeImageURL {                 let fullImage = CIImage(contentsOf: url)                                  // get all the metadata                 self.allPhotoMetadata = fullImage?.properties ?? [:]                                  // {TIFF}                 if let tiffDict = self.allPhotoMetadata["{TIFF}"] as? [String:Any] {                     if tiffDict["Make"] != nil {                         self.cameraData[cameraKeys.make] = tiffDict["Make"]                     }                     if tiffDict["Model"] != nil {                         self.cameraData[cameraKeys.model] = tiffDict["Model"]                     }                     if tiffDict["ImageDescription"] != nil {                         self.imageData[imageKeys.caption] = tiffDict["ImageDescription"]                     }                 }                                  // {IPTC}                 if let iptcDict = self.allPhotoMetadata["{IPTC}"] as? [String:Any] {                     // if we didn't find a caption in the TIFF dict, try to get it from IPTC data                     // first try, Caption/Abtract, then ArtworkContentDescription                     if self.imageData[imageKeys.caption] == nil {                         if iptcDict["Caption/Abstract"] != nil {                             self.imageData[imageKeys.caption] = iptcDict["ArtworkContentDescription"]                         } else if iptcDict["ArtworkContentDescription"] != nil {                             self.imageData[imageKeys.caption] = iptcDict["ArtworkContentDescription"]                         }                     }                 }             }         })     }
9
2
3.5k
Sep ’23
How to get images that are in iCloud with PHPickerViewController?
I have been searching high and low for anyone that has encountered the same issue, My problem is when an image is not actually on the device but rather in iCloud, my app fails to retrieve the image. How would i go about remedying this? My code for PHPicker implementation is as follows, any help would be greatly appreciated. extension PageViewController: PHPickerViewControllerDelegate {       func presentPicker() {     ArtModel.holdingBay.removeAll()     var configuration = PHPickerConfiguration()     configuration.filter = .images     configuration.selectionLimit = 5     let picker = PHPickerViewController(configuration: configuration)     picker.delegate = self     present(picker, animated: true)   }       func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {     if results.count 0 {       for result in results {         result.itemProvider.loadObject(ofClass: UIImage.self, completionHandler: { (object, error) in           if let image = object as? UIImage {             DispatchQueue.main.async {               ArtModel.holdingBay.append(image)             }           }         })       }     }     picker.dismiss(animated: true, completion: self.holdingBayCheck)   }       func holdingBayCheck() {     if ArtModel.holdingBay.count 0 {       performSegue(withIdentifier: K.goToCrop, sender: self)     }   }     }
2
1
1.6k
Oct ’23
Code 3300 error while trying to save a photo to iOS album
While trying to save a photo to a custom album on some devices we get the following error: The operation couldn’t be completed. (PHPhotosErrorDomain error 3300). code: 3300 This is the part of the code where the issue happens PHPhotoLibrary.shared().performChanges({ let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image) guard let placeholder = assetChangeRequest.placeholderForCreatedAsset else { return } let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) albumChangeRequest?.addAssets([placeholder] as NSArray) }, completionHandler: { success, error in completion(success, error) }) I would be thankful for any tips since I am out of ideas.
2
3
4.2k
Oct ’23
iOS16: localIdentifier of PHAsset gets changed after saving to camera roll
Environment: iOS 16 beta 2, beta 3. iPhone 11 Pro, 12 mini Steps to reproduce: Subscribe to Photo Library changes via PHPhotoLibraryChangeObserver, put some logs to track inserted/deleted objects: func photoLibraryDidChange(_ changeInstance: PHChange) { if let changeDetails = changes.changeDetails(for: allPhotosFetchResult) { for insertion in changeDetails.insertedObjects { print("🥶 INSERTED: ", insertion.localIdentifier) } for deletion in changeDetails.removedObjects { print("🥶 DELETED: ", deletion.localIdentifier) } } } Save a photo to camera roll with PHAssetCreationRequest Go to the Photo Library, delete the newly saved photo Come back to the app and watch the logs: 🥶 INSERTED:  903933C3-7B83-4212-8DF1-37C2AD3A923D/L0/001 🥶 DELETED:  39F673E7-C5AC-422C-8BAA-1BF865120BBF/L0/001 Expected result: localIdentifier of the saved and deleted asset is the same string in both logs. In fact: It's different. So it appears that either the localIdentifier of an asset gets changed after successful saving, or it's a bug in the Photos framework in iOS 16. I've checked - in iOS 15 it works fine (IDs in logs match).
2
1
1.4k
Nov ’23
NSCocoaErrorDomain code = 134093 , only in iOS16
i have received a lot of crash log only in iOS16 the crash occured when i called : [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:resultHandler] here is the crash log Exception Type: NSInternalInconsistencyException ExtraInfo: Code Type: arm64 OS Version: iPhone OS 16.0 (20A5328h) Hardware Model: iPhone14,3 Launch Time: 2022-07-30 18:43:25 Date/Time: 2022-07-30 18:49:17 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:Unhandled error (NSCocoaErrorDomain, 134093) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134093 "(null)" Last Exception Backtrace: 0 CoreFoundation 0x00000001cf985dc4 0x1cf97c000 + 40388 1 libobjc.A.dylib 0x00000001c8ddfa68 0x1c8dc8000 + 96872 2 CoreData 0x00000001d56d2358 0x1d56cc000 + 25432 3 CoreData 0x00000001d56fa19c 0x1d56cc000 + 188828 4 CoreData 0x00000001d5755be4 0x1d56cc000 + 564196 5 CoreData 0x00000001d57b0508 0x1d56cc000 + 935176 6 PhotoLibraryServices 0x00000001df1783e0 0x1df0ed000 + 570336 7 Photos 0x00000001df8aa88c 0x1df85d000 + 317580 8 PhotoLibraryServices 0x00000001df291de0 0x1df0ed000 + 1723872 9 CoreData 0x00000001d574e518 0x1d56cc000 + 533784 10 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 11 libdispatch.dylib 0x00000001d520b634 0x1d51f8000 + 79412 12 CoreData 0x00000001d574e0a0 0x1d56cc000 + 532640 13 PhotoLibraryServices 0x00000001df291d94 0x1df0ed000 + 1723796 14 PhotoLibraryServices 0x00000001df291434 0x1df0ed000 + 1721396 15 Photos 0x00000001df8a8380 0x1df85d000 + 308096 16 Photos 0x00000001df89d050 0x1df85d000 + 262224 17 Photos 0x00000001df87f62c 0x1df85d000 + 140844 18 Photos 0x00000001df87ee94 0x1df85d000 + 138900 19 Photos 0x00000001df87e594 0x1df85d000 + 136596 20 Photos 0x00000001df86b5c8 0x1df85d000 + 58824 21 Photos 0x00000001df86d938 0x1df85d000 + 67896 22 Photos 0x00000001dfa37a64 0x1df85d000 + 1944164 23 Photos 0x00000001dfa37d18 0x1df85d000 + 1944856 24 youavideo -[YouaImageManager requestImageDataForAsset:options:resultHandler:] (in youavideo) (YouaImageManager.m:0) 27 25 youavideo -[YouaAlbumTransDataController requstTransImageHandler:] (in youavideo) (YouaAlbumTransDataController.m:0) 27 26 youavideo -[YouaAlbumTransDataController requstTransWithHandler:] (in youavideo) (YouaAlbumTransDataController.m:77) 11 27 youavideo -[YouaUploadTransDataOperation startTrans] (in youavideo) (YouaUploadTransDataOperation.m:102) 19 28 Foundation 0x00000001c9e78038 0x1c9e3c000 + 245816 29 Foundation 0x00000001c9e7d704 0x1c9e3c000 + 268036 30 libdispatch.dylib 0x00000001d51fa5d4 0x1d51f8000 + 9684 31 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 32 libdispatch.dylib 0x00000001d51ff58c 0x1d51f8000 + 30092 33 libdispatch.dylib 0x00000001d51febf4 0x1d51f8000 + 27636 34 libdispatch.dylib 0x00000001d520db2c 0x1d51f8000 + 88876 35 libdispatch.dylib 0x00000001d520e338 0x1d51f8000 + 90936 36 libsystem_pthread.dylib 0x00000002544b9dbc 0x2544b9000 + 3516 37 libsystem_pthread.dylib 0x00000002544b9b98 0x2544b9000 + 2968 i can't find the error code 134093 definition i don't know what's going wrong in iOS16 Would anyone have a hint of why this could happen and how to resolve it? thanks very much
7
5
2.8k
Jun ’24
Swift: Save image with file name using PHPhotoLibrary and PHAssetCreationRequest
I  am trying to save an image to the user's photo library using PHPhotoLibrary and set the image file name at the time of saving suing the code below. This is working the first time, but if I then try to save the same image again with a different file name, it saves with the same file name as before. Is there something I need to add to let the system know to save a new version of the image with a new file name? Thank you PHPhotoLibrary.shared().performChanges ({ let assetType:PHAssetResourceType = .photo let request:PHAssetCreationRequest = .forAsset() let createOptions:PHAssetResourceCreationOptions = PHAssetResourceCreationOptions() createOptions.originalFilename = "\(fileName)" request.addResource(with: assetType, data: image.jpegData(compressionQuality: 1)!, options: createOptions) }, completionHandler: { success, error in if success == true && error == nil { print("Success saving image") } else { print("Error saving image: \(error!.localizedDescription)") } })
3
0
2.0k
Aug ’23
PHPicker fails to load RAW images
We observed that the PHPicker is unable to load RAW images captured on an iPhone in some scenarios. And it is also somehow related to iCloud. Here is the setup: The PHPickerViewController is configured with preferredAssetRepresentationMode = .current to avoid transcoding. The image is loaded from the item provider like this: if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage) { itemProvider.loadFileRepresentation(forTypeIdentifier: kUTTypeImage) { url, error in // work } } This usually works, also for RAW images. However, when trying to load a RAW image that has just been captured with the iPhone, the loading fails with the following errors on the console: [claims] 43A5D3B2-84CD-488D-B9E4-19F9ED5F39EB grantAccessClaim reply is an error: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}} Error copying file type public.image. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.image" UserInfo={NSLocalizedDescription=Cannot load representation of type public.image, NSUnderlyingError=0x280480540 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}}}} We observed that on some devices, loading the image will actually work after a short time (~30 sec), but on others it will always fail. We think it is related to iCloud Photos: On the device that has iCloud Photos sync enabled, the picker is able to load the image right after it was synced to the cloud. On devices that don't sync the image, loading always fails. It seems that the sync process is doing some processing (?) of the image that will later enable the picker to load it successfully, but that's just guessing. Additional observations: This seems to only occur for images that were taken with the stock Camera app. When using Halide to capture RAW (either ProRAW or RAW), the Picker is able to load the image. When trying to load the image as kUTTypeRawImage instead of kUTTypeImage, it also fails. The picker also can't load RAW images that were AirDroped from another device, unless it synced to iCloud first. This is reproducable using the Selecting Photos and Videos in iOS sample code project. We observed this happening in other apps that use the PHPicker, not just ours. Is this a bug, or is there something that we are missing?
5
1
1.9k
Sep ’23
In iOS16,There was a crash when use [PHAssetCollection fetchAssetCollectionsWithType:subtype:options:]
On some iOS 16 mobile phones, it was found that there was a crash when using photo book to read the album. When the crash occurred, the console did not print any information. Through the xcodef stack, the crash occurred in the corresponding interface inside photo book, in the order of [PLPrivacy logPhotosAccessWithSelfAuditToken], -[PAAccessLogger log:], _ pthread_ wqthread, _ dispatch _ workloop_ worker_ thread, _ dispatch_ lane_ invoke, _ dispatch_ lane_ serial _ drain, _ dispatch _ client_ callout, _ dispatch_ block_ async invoke2, -[PAAccessLogger log:]_ block _ invoke, -[PACoalescingIntervalTracker coalesce:], _ dispatch_ source_ set_ runloop_ timer_ 4CF,
1
0
643
Jul ’23
Modify the ProRAW pixel buffer to write a modified DNG
Hello, In one of my apps, I'm trying to modify the pixel buffer from a ProRAW capture to then write the modified DNG. This is what I try to do: After capturing a ProRAW photo, I work in the delegate function func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) { ... } In here I can access the photo.pixelBuffer and get its base address: guard let buffer = photo.pixelBuffer else { return } CVPixelBufferLockBaseAddress(buffer, []) let pixelFormat = CVPixelBufferGetPixelFormatType(buffer) // I check that the pixel format corresponds with ProRAW . This is successful, the code enters the if block if (pixelFormat == kCVPixelFormatType_64RGBALE) { guard let pointer = CVPixelBufferGetBaseAddress(buffer) else { return } // We have 16bits per component, 4 components let count = CVPixelBufferGetWidth(buffer) * CVPixelBufferGetHeight(buffer) * 4 let mutable = pointer.bindMemory(to: UInt16.self, capacity: count) // As a test, I want to replace all pixels with 65000 to get a white image let finalBufferArray : [Float] = Array.init(repeating: 65000, count: count) vDSP_vfixu16(finalBufferArray, 1, mutable, 1, vDSP_Length(finalBufferArray.count)) // I create an vImage Pixel buffer. Note that I'm referencing the photo.pixelBuffer to be sure that I modified the underlying pixelBuffer of the AVCapturePhoto object let imageBuffer = vImage.PixelBuffer<vImage.Interleaved16Ux4>(referencing: photo.pixelBuffer!, planeIndex: 0) // Inspect the CGImage let cgImageFormat = vImage_CGImageFormat(bitsPerComponent: 16, bitsPerPixel: 64, colorSpace: CGColorSpace(name: CGColorSpace.displayP3)!, bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue | CGBitmapInfo.byteOrder16Little.rawValue))! let cgImage = imageBuffer.makeCGImage(cgImageFormat: cgImageFormat)! // I send the CGImage to the main view controller. This is successful, I can see a white image when rendering the CGImage into a UIImage. This lets me think that I successfully modified the photo.pixelBuffer firingFrameDelegate?.didSendCGImage(image: cgImage) } // Now I try to write data. Unfortunately, this does not work. The photo.fileDataRepresentation() writes the data corresponding to the original, unmodified pixelBuffer `if let photoData = photo.fileDataRepresentation() { // Sending the data to the view controller and rendering it in the UIImage displays the original photo, not the modified pixelBuffer firingFrameDelegate?.didSendData(data: photoData) thisPhotoData = photoData }` CVPixelBufferUnlockBaseAddress(buffer, []) The same happens if I try to write the data to disk. The DNG file displays the original photo and not the data corresponding to the modified photo.pixelBuffer. Do you know why this code should not work? Do you have any ideas on how I can modify the ProRAW pixel buffer so that I can write the modified buffer into a DNG file? My goal is to write a modified file, so, I'm not sure I can use CoreImage of vImage to output a ProRAW file.
1
0
1.1k
Oct ’23
Unable to change Photos permission of iPad app on Mac
Users can run our apps on Macs with Apple Silicon via the "iPad Apps on Mac" feature. The apps use PHPhotoLibrary.requestAuthorization(for: .addOnly, handler: callback) to request write-only access to the user's Photo Library during image export. This works as intended on macOS, but a huge problem arises when the user denies access (by accident or intentionally) and later decides that they want us to add their image to Photos: There is no way to grant this permission again. In System Preferences → Privacy &amp;amp; Security → Photos, the app is just not listed – in fact, none of the "iPad Apps on Mac" apps appear here. Not even tccutil reset all my.bundle.id works. It just reports tccutil: Failed to reset all approval status for my.bundle.id. Uninstalling, restarting the Mac, and reinstalling the app also doesn't work. The system seems to remember the initial decision. Is this an oversight in the integration of those apps with macOS, or are we missing something fundamental here? Is there maybe a way to prompt the user again?
3
3
1.1k
Sep ’23
Time zone for PHAsset creationDate
Dear Experts, PHAsset.creationDate is an NSDate, which does not have a timezone associated with it, right? Consider a photo viewer app. If I take a photo of the sunrise at 0600 local time while I am away, when I get home and view the photo in the app, I believe I want the timestamp shown with the photo to be 0600. Do you agree? But NSDate is just a time-point, and I don't think Foundation (or anything else in iOS) has a type that combines a time-point with a time zone. Nor does PHAsset have any other useful attributes - unless I were to determine the time zone from the location! Am I missing anything?
3
1
1.1k
Nov ’23
Handling cancel button in SwiftUI PhotoPicker (inline)
Using the new inline PhotosPicker style in iOS 17, it isn't made clear how to handle the cancel button's input, and i cannot seem to find an answer in the documentation. PhotosPicker( "Select picture", selection: $selected, selectionBehavior: .default, photoLibrary: .shared() ) .photosPickerStyle(.inline) Does anybody have a solution or is this a bug that needs to be fixed?
3
0
1.6k
Jan ’24
Webview, photolibrary,Camera, choose files
I have a safari webkit inside my mobile app which renders a webpage. The webpage has File upload option. when I click on it 3 options are shown as in screenshot. I am trying to make the safari kit to only allow Camera capture and hide Upload already existing files.  Is there any safari permission which I can remove to configuration that hide the options of upload from files.
2
0
1.1k
Jul ’23
Dismiss keyboard for PHPickerViewController not working
I'm using PHPickerViewController in my app and I want to keep it open even after the user selects an image. My flow is the following: after the user select the photo, another viewController is presented modally over it, displaying the selected photo. The user can dismiss this viewController and come back to the picker. The issue is that in case the keyboard is open in the PHPickerViewController and I select an image, the keyboard is not dismissed no matter what I do. I tried the following: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { guard let provider = results.first?.itemProvider else { return } if provider.canLoadObject(ofClass: UIImage.self) { provider.loadObject(ofClass: UIImage.self) { image, _ in guard let image = image as? UIImage else { print("Error converting image") return } DispatchQueue.main.async { [weak self] in self?.dismissKeyboard() // -> HERE I TRY TO DISMISS THE KEYBOARD self?.presentImagePreviewViewController(image: image) } } } } func dismissKeyboard() { // NONE OF THESE DISMISS THE KEYBOARD phPickerViewController?.view.endEditing(true) phPickerViewController?.view.resignFirstResponder() view.endEditing(true) view.resignFirstResponder() UIApplication.shared.sendAction( #selector(UIApplication.resignFirstResponder), to: nil, from: nil, for: nil) UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) } I am assuming that this is because the picker runs on a separate process and doesn't get the dismiss keyboard notification. As per the documentation here. Displaying the photo library doesn’t need user permission because it’s running in a separate process. Can I dismiss the keyboard in any other way?
0
0
520
Jul ’23