Post

Replies

Boosts

Views

Activity

PHPicker remove provider.loadItem(forTypeIdentifier:) can not load URL anymore from IOS 16.6
I use loadFileRepresentation to register video URL. After that, loadItem will take less time to see the video from the picker. But after upgrade Iphone to 16.6, this func can not work. Have any change or dev team removed loadItem it? Here is my sample code: provider.loadItem(forTypeIdentifier: "public.movie", options: nil) { url, error in guard let url = url as? URL else { return } self.parent.selectedVideoURL = url // Check cached, if loadFileRepresentation before use url from loadItem more faster let storage = LocalStorageHelper() if storage.checkStringExistStorage(MEDIA_PICKER_STORAGE_NAMESPACE, url.relativeString) { DispatchQueue.main.async { self.parent.presentationMode.wrappedValue.dismiss() self.parent.videoURL = url } } else { provider.loadFileRepresentation(forTypeIdentifier: "public.movie") { urlResult, error in DispatchQueue.main.async { self.parent.presentationMode.wrappedValue.dismiss() } if let error = error { // Handle errors loading video LOGGING.error("Error loading video: \(error.localizedDescription)") return } guard let urlFile = urlResult else {return} // create a new filename let fileName = "\(Int(Date().timeIntervalSince1970)).\(urlFile.pathExtension)" // create new URL let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName) // copy item to APP Storage try? FileManager.default.copyItem(at: urlFile, to: newUrl) DispatchQueue.main.async { storage.saveStringToStorage(MEDIA_PICKER_STORAGE_NAMESPACE, url.relativeString) self.parent.videoURL = URL(string: newUrl.absoluteString) } } } }
1
0
617
Aug ’23
Big data with custom annotations in MKMapView, over 10k annotations
I used clustering annotations for display issues. But I meet problem when my data gradually increase, detail: I load annotation with my custom UIImageView and load Image from network to put into UIImageView When 1k images => it no lagging from here. But when reach 10k images => view meet lagging. Have any solution for big data on MKMapView? Here is my code for annotation example class PhotoAnnotationView: MKAnnotationView { private var imageView = UIImageView() override init(annotation: MKAnnotation?, reuseIdentifier: String?) { super.init(annotation: annotation, reuseIdentifier: reuseIdentifier) self.frame = CGRect(x: 0, y: 0, width: 50, height: 50) self.imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) self.addSubview(self.imageView) self.imageView.layer.cornerRadius = 5.0 self.imageView.layer.masksToBounds = true self.canShowCallout = false self.clusteringIdentifier = "point" } override var annotation: MKAnnotation? { willSet { clusteringIdentifier = "point" if let mapAnnotation = newValue as? PhotoAnnotation, let url = URL(string: mapAnnotation.imageURL) { self.configure(with: url) } } } override var image: UIImage? { get { return self.imageView.image } set { self.imageView.image = newValue } } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func prepareForReuse() { super.prepareForReuse() } func configure(with imageURL: URL) { let options = ImageLoadingOptions( placeholder: nil, transition: .none ) ****.loadImage(with: imageURL, options: options, into: imageView) } }
1
0
483
Oct ’23
[IOS 17] Bug when save video from URL and read it by PHPickerViewController
From IOS 17. Have an issue when saving video and reading it from PHPickerViewController. Video become into jpeg file Code save video and I saw reason because i changed creationDate. But IOS 16 no bug here doVertifyAccessAblum() { DispatchQueue.global(qos: .background).async { if let url = URL(string: videoURL), let urlData = NSData(contentsOf: url) { let galleryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]; let filePath="\(galleryPath)/\(url.lastPathComponent).mp4" DispatchQueue.main.async { urlData.write(toFile: filePath, atomically: true) PHPhotoLibrary.shared().performChanges({ let changeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: URL(fileURLWithPath: filePath)) changeRequest?.creationDate = Date() }) { success, error in LOGGING.debug("Save video with status: success=\(success) error=\(String(describing: error))") } } } } } }
5
1
710
Dec ’23