YPImagePicker
YPImagePicker copied to clipboard
preSelectItemOnMultipleSelection not work
config.library.preSelectItemOnMultipleSelection = false
I also tried below code and combination. config.library.preselectedItems = nil (or config.library.preselectedItems = [])
But first Item is always selected.
@peymankh @s4cha I have the exact same problem, +1
@s4cha Can certainly reproduce the issue now.
We always have an item preselected in refreshMediaRequest
being called from initialize
. This used to be cleared out in showMultipleSelection
but now has moved to multipleSelectionButtonTapped
to preserve the selection.
Not entirely sure what to change here not to break current functionality, would be great if you could have a look as well and let me know what needs to be changed.
I have put a fix in place, it does resolve the problem! Hopefully won't break the current pre-selection functionality.
@Ludotrico and @uxight Feel free to give my branch a go and let me know if that resolves your issue.
@peymankh thank you for the fix, it seems to work well.
However, I do not believe it is the best way to approach it. Any ideas @s4cha @NikKovIos?
I think the problem is refreshMediaRequest() function in initialize() refreshMediaRequest calls addToSelection(indexPath: IndexPath(row: 0, section: 0)) because in that time multipleSelectionEnabled is not true yet.
so I add parameter like this: refreshMediaRequest(needsDefaultSelection: Bool = true)
and fix in initialize() to: ... refreshMediaRequest(needsDefaultSelection: YPConfig.library.defaultMultipleSelection ? false : true) ...
fix in refreshMediaRequest() to: ... if !multipleSelectionEnabled && needsDefaultSelection { addToSelection(indexPath: IndexPath(row: 0, section: 0)) } ...
This fixed my problems
@peymankh @s4cha
@uxight make sure to tag users (@peymankh) that you are intending to communicate with.