Comments (6)
config.fetchAssetCollection = TestPhotoFetchAssetCollection.self
public struct TestPhotoFetchAssetCollection: PhotoFetchAssetCollection {
public static func fetchCameraAssetCollection(_ config: PickerConfiguration, options: PHFetchOptions) -> PhotoAssetCollection? {
if /*自定义默认显示的相册*/ {
if config.creationDate {
options.sortDescriptors = [
NSSortDescriptor(
key: "creationDate",
ascending: config.creationDate
)
]
}
var collection: PhotoAssetCollection?
fetchAssetCollections(options: options) { assetCollection, isCameraRoll, stop in
if !isCameraRoll {
collection = assetCollection
stop.pointee = true
}
}
if let collection {
return collection
}
}
return DefaultPhotoFetchAssetCollection.fetchCameraAssetCollection(config, options: options)
}
}
from hxphotopicker.
你好, 按照上边的方式实现了, 我们采用albumShowMode方式为popup,有点小问题, 比如自定义相册为'xxx', 弹出后点击上边的标题展示albumList会发现显示的是'xxx',但是列表选中的却是'最近项目', 切换几次后'最近项目'又不见被替换为'xxx'了,这时列表里有2个'xxx'相册, 虽然可以修改自定义相册collection.isSelected = true
稳定这种情况, 但是我们希望弹出相册列表时默认选中的是'xxx',同时'最近项目'也存在,这样可以实现吗?
_ config: PickerConfiguration,
options: PHFetchOptions
) -> PhotoAssetCollection? {
if config.creationDate {
options.sortDescriptors = [
NSSortDescriptor(
key: "creationDate",
ascending: config.creationDate
)
]
}
var collection: PhotoAssetCollection?
fetchAssetCollections(options: options) { assetCollection, isCameraRoll, stop in
if !isCameraRoll, assetCollection.albumName == "xxx" {
collection = assetCollection
stop.pointee = true
}
}
if let collection {
// collection.isSelected = true
return collection
}
return DefaultPhotoFetchAssetCollection.fetchCameraAssetCollection(config, options: options)
}```
![image](https://github.com/SilenceLove/HXPhotoPicker/assets/12481783/5d31afad-848d-4c9b-8fcd-b3db4aa899e4)
from hxphotopicker.
我发现可以自定义PhotoFetchData,但是在重写fetchAssetCollections
时遇到了一些问题,
这两个属性没有public,重写的时候无法使用.
我发现'最近项目'是下边这句代码替换掉的
所以我想重写这个方法,不知道重写这个方法是否可行,感觉重写后的select状态依然有些混乱.
from hxphotopicker.
你好, 按照上边的方式实现了, 我们采用albumShowMode方式为popup,有点小问题, 比如自定义相册为'xxx', 弹出后点击上边的标题展示albumList会发现显示的是'xxx',但是列表选中的却是'最近项目', 切换几次后'最近项目'又不见被替换为'xxx'了,这时列表里有2个'xxx'相册, 虽然可以修改自定义相册
collection.isSelected = true
稳定这种情况, 但是我们希望弹出相册列表时默认选中的是'xxx',同时'最近项目'也存在,这样可以实现吗?_ config: PickerConfiguration, options: PHFetchOptions ) -> PhotoAssetCollection? { if config.creationDate { options.sortDescriptors = [ NSSortDescriptor( key: "creationDate", ascending: config.creationDate ) ] } var collection: PhotoAssetCollection? fetchAssetCollections(options: options) { assetCollection, isCameraRoll, stop in if !isCameraRoll, assetCollection.albumName == "xxx" { collection = assetCollection stop.pointee = true } } if let collection { // collection.isSelected = true return collection } return DefaultPhotoFetchAssetCollection.fetchCameraAssetCollection(config, options: options) }``` ![image](https://github.com/SilenceLove/HXPhotoPicker/assets/12481783/5d31afad-848d-4c9b-8fcd-b3db4aa899e4)
这个问题下个版本会修改,不会替换掉第一个相册
from hxphotopicker.
试了最新的修改代码后相册已经不会被替换掉了, 然而发现有一个bug:
https://github.com/SilenceLove/HXPhotoPicker/assets/12481783/927e7131-99b0-4a49-bbb0-dc5862c44434
视频中可以看到打开自定义相册后选中状态有些错乱, 我调试了下大概知道原因:
self.cameraAssetCollection
可能还没拿到的时候已经走到这个if判断里, 看起来2个queue执行完毕的先后顺序并不能确定,所以时好时坏.
from hxphotopicker.
最新的代码试试
from hxphotopicker.
Related Issues (20)
- 你好,有一个问题:双击放大后,滑动至下一张图片,再滑动回来,此时图片已恢复初始大小,再双击,图片会缩小 HOT 1
- NSInternalInconsistencyException崩溃 HOT 1
- <unknown>:0: error: circular reference
- 阿语环境下使用PhotoBrowser浏览图片有问题 HOT 3
- 代码功能建议 HOT 3
- 使用OC调用Swift获取照片与视频耗时太长了,能否优化呢? HOT 1
- 如何获取视频的原始名称呢 HOT 3
- 大佬 增加一下RTL适配呗 目前阿拉伯语的UI布局有点点问题 HOT 1
- 近距离拍摄无法聚焦的问题 HOT 2
- Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file HXPhotoPicker/PhotoPreviewContentVideoView.swift, line 97 2024-06-25 16:46:19.950345+0800 996[21232:6601403] Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file HXPhotoPicker/PhotoPreviewContentVideoView.swift, line 97 HOT 6
- ▿ Result<AssetURLResult, AssetError> ▿ failure : PHAssetResource写入数据错误: Error Domain=PHPhotosErrorDomain Code=-1 "(null)" - assetResourceWriteDataFailed : Error Domain=PHPhotosErrorDomain Code=-1 "(null)" HOT 7
- 关于photolist标题字体的问题 HOT 3
- 仅图片选择时,退出预览页闪退 HOT 2
- 崩溃问题 HOT 6
- 手动导入框架,Task报错 HOT 1
- 适配Swift严格并发检查 HOT 1
- SwiftUIExample点击“完成”后无效 HOT 1
- HEVC格式的视频保存失败- iPhone12、iOS17.2自带相机拍摄 HOT 2
- Edited Result HOT 3
- Demo swiftUI 点击无法调起相册 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hxphotopicker.