You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using WaterdallGrid, if there are less than 2 data to display, nothing will be displayed.
Here is a piece of source code that reproduces the bug at my end
ScrollView{WaterfallGrid(dataArray, id: \.self){ file inVStack{
if let post = viewModel.posts.first(where:{ $0.fileIds.contains(file.id)}){NavigationLink(destination:ImageDetailView(item: post, file: file)){
// View to display images.
ImageGridItem(url: file.url!)}}}}}
@yamanetaisei. It's not limited by the exact number (2). Such things happen when the number of items are less or equal than number of columns in your grid. I guess you saw 2 is making the difference just becasue the default number of columns is 2.
Furthermore, I feel this bug should come from the logic how waterallgrid calcualtes the width of each item. @xiaoxidong Then seems not easy to fix it. But a workaround is to add some blank item in your items to make its length larger than number of columns.
Thanks
Dongqing
.gridStyle(
columnsInPortrait:maxColumns(max:2),
columnsInLandscape:maxColumns(max:3),
spacing:4)func maxColumns(max:Int)->Int{
// images is an array holding the images and its data
lethighestMatchIndex=min(max, images.count -1)return highestMatchIndex
}
Hi all, I have found a bug.
When using WaterdallGrid, if there are less than 2 data to display, nothing will be displayed.
Here is a piece of source code that reproduces the bug at my end
Please some advice or fix
The text was updated successfully, but these errors were encountered: