Switching from different albums is not working
Closed this issue · 1 comments
SamuelFolledo commented
Hi after copying the Example, the Controller doesnt show the Camera Roll on the navigation bar to switch to different albums like in the gif demo. How do we switch albums?
lazy var imagePicker: ImagePickerController = {
let imagePicker = ImagePickerController()
imagePicker.settings.selection.max = 1
imagePicker.settings.theme.selectionStyle = .checked
imagePicker.settings.selection.unselectOnReachingMax = true
imagePicker.settings.fetch.assets.supportedMediaTypes = [.image] //fetch images only
imagePicker.albumButton.tintColor = .blue
imagePicker.cancelButton.tintColor = .blue
imagePicker.doneButton.tintColor = .blue
imagePicker.navigationBar.barTintColor = UIColor.systemBackground
imagePicker.settings.theme.backgroundColor = .systemGray6
imagePicker.settings.theme.selectionFillColor = .blue
imagePicker.settings.theme.selectionStrokeColor = .gray
imagePicker.settings.theme.selectionShadowColor = .blue
imagePicker.settings.theme.previewTitleAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16),NSAttributedString.Key.foregroundColor: UIColor.label]
imagePicker.settings.theme.previewSubtitleAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12),NSAttributedString.Key.foregroundColor: UIColor.label]
imagePicker.settings.theme.albumTitleAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18),NSAttributedString.Key.foregroundColor: UIColor.label]
imagePicker.settings.list.cellsPerRow = {(verticalSize: UIUserInterfaceSizeClass, horizontalSize: UIUserInterfaceSizeClass) -> Int in
switch (verticalSize, horizontalSize) {
case (.compact, .regular): // iPhone5-6 portrait
return 3
case (.compact, .compact): // iPhone5-6 landscape
return 3
case (.regular, .regular): // iPad portrait/landscape
return 4
default:
return 3
}
}
return imagePicker
}()
bivant commented
Hello @SamuelFolledo
You have to specify the albums you want to show, the default value set to "smart Album" only.
//Show the "Recent" album and all other ones available
let options = imagePicker.settings.fetch.album.options
imagePicker.settings.fetch.album.fetchResults = [
PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary, options: options),
PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumRegular, options: options),
]