photokit

PHPhotoLibrary.requestAuthorization(for:, handler:) does not calls handler block

送分小仙女□ 提交于 2021-01-29 07:01:18
问题 I use new API for requesting of access for an assets library of a user: PHPhotoLibrary.requestAuthorization(for: .readWrite) { [weak self] (status:PHAuthorizationStatus) in print("called"); } iOS displays alert with access levels: If the user selects Select Photos... , iOS will show a picker: If user swipes down on a title of the picker, the photos library will not call the handler block. Implementation of the photoLibraryDidChange func photoLibraryDidChange(_ changeInstance: (PHChange)) {

IOS照片框架

孤者浪人 提交于 2020-02-27 07:12:52
介绍 每天,用 iPhone 拍摄的照片 数量超过了任何相机。每年 iOS 设备上的显示效果变得越来越好,回到 iPad 刚出现 还没有 Retina 显示屏的时代,大屏幕的杀手级功能之一就是可以展示用户照片和浏览器照片库。自从相机成为 iPhone 最重要和最受欢迎的功能开始,对能管理和加工用户照片库中宝贵的照片的应用程序和工具就有着巨大的需求。 直到 2014 年夏天前,开发者只能用 AssetsLibrary 框架 访问日益增长的用户的照片库。几年以来,相机应用和照片应用发生了显著的变化,增加了许多新特性,包括按时刻来组织照片的方式。但与此同时,AssetsLibrary 框架却没有跟上步伐。 随着 iOS 8 的到来,苹果给我们提供了一个现代化的框架 —— PhotoKit,它比 AssetsLibrary 表现更好,并且拥有让应用和设备照片库无缝工作的特性。 概要 我们将从 框架对象模型 的鸟瞰图开始:实体和实体间的关系,获取实体的实例,以及使用获取的结果进行工作。 除此之外,我们的讲解还会涉及到一些在使用 AssetsLibrary 时,尚未对开发者开放的 资源元数据 。 然后我们会讨论 加载资源的图像数据 :过程本身,大量可用的选项,一些陷阱和边界案例。 最后,我们会谈谈通过外部参与者来 观察照片库的变化 ,学习如何创建和提交我们 自己修改的改变 。 PhotoKit

iOS 开发之照片框架详解

风流意气都作罢 提交于 2020-02-22 15:21:53
一. 概要 在 iOS 设备中,照片和视频是相当重要的一部分。最近刚好在制作一个自定义的 iOS 图片选择器,顺便整理一下 iOS 中对照片框架的使用方法。在 iOS 8 出现之前,开发者只能使用 AssetsLibrary 框架来访问设备的照片库,这是一个有点跟不上 iOS 应用发展步伐以及代码设计原则但确实强大的框架,考虑到 iOS7 仍占有不少的渗透率,因此 AssetsLibrary 也是本文重点介绍的部分。而在 iOS8 出现之后,苹果提供了一个名为 PhotoKit 的框架,一个可以让应用更好地与设备照片库对接的框架,文末也会介绍一下这个框架。 另外值得强调的是,在 iOS 中,照片库并不只是照片的集合,同时也包含了视频。在 AssetsLibrary 中两者都有相同类型的对象去描述,只是类型不同而已。文中为了方便,大部分时候会使用「资源」代表 iOS 中的「照片和视频」。 二. AssetsLibrary 组成介绍 AssetsLibrary 的组成比较符合照片库本身的组成,照片库中的完整照片库对象、相册、相片都能在 AssetsLibrary 中找到一一对应的组成,这使到 AssetsLibrary 的使用变得直观而方便。 AssetsLibrary : 代表整个设备中的资源库(照片库),通过 AssetsLibrary 可以获取和包括设备中的照片和视频

How to get requested image size for iOS8 PhotoKit?

强颜欢笑 提交于 2020-01-31 03:28:07
问题 I am using the code below for fetching an image: [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(800, 600) contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage *result, NSDictionary *info) { NSLog(@"size:%@",NSStringFromCGSize(result.size)); }]; I'm requesting an image size of 800 x 600, but I'm getting an image size of 45 x 60, which is very poor-quality. How can i get the requested image size using PhotoKit ? 回答1: Your (Unnati's)

Delete in PhotoKit: can you skip “Recently Deleted”?

…衆ロ難τιáo~ 提交于 2020-01-06 14:11:43
问题 As of iOS8, when you delete a photo, it goes into a trashcan-analog called "Recently Deleted". This happens when you delete via Photos.app, or via the PhotoKit API (using PHAssetChangeRequest.deleteAssets() ). In Photos.app, you can then go into "Recently Deleted", and really delete that photo. Is there a way to do that in PhotoKit? 回答1: Nope. The only deletion API is deleteAssets . 来源: https://stackoverflow.com/questions/29885416/how-to-remove-photos-from-ios-camera-roll

Crash upon CGImageDestinationFinalize

主宰稳场 提交于 2020-01-02 00:53:13
问题 My app allows users to edit photos using the Photos framework. I am seeing some crash reports, and it appears the crash occurs when generating the output image, but I am not sure where the problem lies. This crash is occurring on multiple hardware devices and multiple versions of iOS 9 including the latest 9.1. The last call my app makes is CGImageDestinationFinalize in order to create the edited image NSData . The crash reports show that calls continue in the CoreImage space before the crash

How to access NSData/NSURL of slow motion videos using PhotoKit

感情迁移 提交于 2019-12-29 04:52:08
问题 Working with new Photo framework, I can access the NSData of PHAssets using requestImageDataForAsset . I can also access the file URL using the PHImageFileURLKey of the returned info NSDictionary . [[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { //imageData contains the correct data for images and videos NSLog(@"info - %@", info); NSURL* fileURL = [info

iOS PhotoKit: Fetch all smart albums except panoramas

谁说我不能喝 提交于 2019-12-20 04:23:09
问题 I am using the follow code to fetch all smart albums: PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.smartAlbum, subtype: PHAssetCollectionSubtype.albumRegular, options: nil) How can I exclude the Panoramas smart album from this fetch? I assume I have to add a predicate using the options param, but I don't know how to format the predicate. 回答1: If you want to exclude the Panoramas, consider using an array and fetching only the collection you need. In other words,

Exporting video using PhotoKit (PHAsset) gives different video file every time

独自空忆成欢 提交于 2019-12-18 18:04:10
问题 I use the method (a the end of this question) to retrieve video from the device. What it does, it finds the first video in the library, creates export session and exports the video into MOV file. After two runs of the application (stopping the app between method runs), two resulting files are being compared. Both files are different. I was expecting that both files would be the same, as the same asset is being exported. One more remark: running the method twice in the same application run

How do I determine if a PHAsset in a PHFetchResult represents a deleted photo?

萝らか妹 提交于 2019-12-18 11:57:14
问题 I'm trying to grab a thumbnail of the last photo taken on a device using the new Photos framework in iOS 8. The code I have right now to do this is the following: PHFetchOptions *fetchOptions = [PHFetchOptions new]; fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]]; PHFetchResult *assetsInfo = [PHAsset fetchAssetsWithOptions:fetchOptions]; PHImageRequestOptions *requestOptions = [PHImageRequestOptions new]; requestOptions.version =