ios - 有没有办法获取我的 iOS 应用程序屏幕截图列表?

标签 ios objective-c swift uiimagepickercontroller screenshot

有没有办法在我的 iOS 应用程序中访问从我的应用程序截取的所有屏幕截图?

如果不可能,有没有办法只用截图相册(来自所有应用程序)打开图像选择器 Controller (UIImagePickerController)?

谢谢。

最佳答案

除了此处定义的源类型之外,无法呈现标准的 UIImagePickerController

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImagePickerController_Class/#//apple_ref/c/tdef/UIImagePickerControllerSourceType

但是,有一种方法可以抓取屏幕截图的相册并将其显示在自己的 UI 中。根据文档,您可以执行以下操作:

let options = PHFetchOptions()
options.predicate = NSPredicate(format: "localizedTitle = Screenshots")
let collections = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .Any, options: options)
let sceenShots = collections.firstObject as? PHAssetCollection

但是由于错误(上面会因为谓词而崩溃)你可以获取所有相册然后过滤截图的相册(适用于 iOS8+)

let collections = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .Any, options: nil)
var screenshots: PHAssetCollection?
collections.enumerateObjectsUsingBlock {
    (collection, _, _) -> Void in
    if collection.localizedTitle == "Screenshots" {
        screenshots = collection as? PHAssetCollection
    }
}

或者如果你的目标是 iOS9+,你可以这样做:

let collections = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .SmartAlbumScreenshots, options: nil)
let screenshots = collections.lastObject as? PHAssetCollection

另请注意,无法从特定应用程序中获取屏幕截图。

关于ios - 有没有办法获取我的 iOS 应用程序屏幕截图列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35648972/

相关文章:

android - 使用 DataBase iOS 和 Android 发送应用程序

c# - 禁用 Linea Pro 5 扫描仪而不调用 Disconnect

ios - iOS 6 上的 UIWebView 和客户端证书

php - 将方法 nsdictionary 发布到 json 对象 iOS objective-c

UITextView AppStore 拒绝中的 HTML 字符串

ios - iOS应用中的GPL库没有开源吗?

ios - UINavigationBar 中后退按钮标题的问题

ios - 如何检查某个对象是否存在于 NSMutableArray 的某个索引处?

ios - 快速更改 CAShapeLayer 变换的动画持续时间

swift - 在 Swift 中找不到结构类型的成员 <方法名称>