Posts

Post not yet marked as solved
0 Replies
241 Views
Hello, so I started using Compositional layout for cases where previously I would use either a Table View or Collection View with the Flow layout. While Compositional works great for complex layout, I have a bit of an issue building simple screens. For example one header cell and then three tappable cells below it. let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: height) let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) let layoutGroup = NSCollectionLayoutGroup.vertical(layoutSize: itemSize, subitems: [layoutItem]) I am using this setup to setup the only group that gets passed to the NSCollectionLayoutSection and it works great, but I dont know what is the best way to specify height? I am using .estimated(200) for now, but this in the end (correctly) results in header that has height like 300 and then those buttons with 45 each. I just feel like I am not using the Compositional layout sizing properly. Thanks for help.
Posted
by nemecek_f.
Last updated
.
Post not yet marked as solved
12 Replies
3.4k Views
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!
Posted
by nemecek_f.
Last updated
.
Post marked as solved
1 Replies
606 Views
Hello, does PHPhotoPickerViewController offer any options to specify which resolution should the selected video to be? Meaning can it do automatic compression like UIImagePickerViewController with videoExportPreset settings? Or is this supposed to be handled in the app itself? Say I want to always have Full HD or 4K videos (if available) how would I go about achieving that? Thanks
Posted
by nemecek_f.
Last updated
.
Post marked as solved
2 Replies
700 Views
I am using UIImagePickerController to let users pick videos to use in my app. However I noticed that best quality I am able to get is 1280x720 probably because of the compression that always happen. These videos are 4K and I would like to get this resolution or at least 1080p. Here is my code for creating picker: let picker = UIImagePickerController() picker.delegate = self picker.videoQuality = .typeHigh picker.sourceType = .photoLibrary picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary) ?? [] assert(!picker.mediaTypes.isEmpty) picker.mediaTypes = ["public.movie"] picker.allowsEditing = true present(picker, animated: true, completion: nil) Modifying allowsEditing or videoQuality does not do anything. Thanks for help!
Posted
by nemecek_f.
Last updated
.