Questions tagged [lazyvgrid]
131 questions
2
votes
0 answers
SwiftUI - how to expand items within a row to fill available space
UPDATE 14/06
I have come up with a hacked way of getting the result I want, but it is not ideal.
Using the following extension (from https://www.hackingwithswift.com/example-code/language/how-to-split-an-array-into-chunks) I can chunk my array of…

DevB1
- 1,235
- 3
- 17
- 43
2
votes
1 answer
SwiftUI LazyVGrid transition animation not as expected
I have a LazyVGrid that is defined like this:
let column = Array(repeating: GridItem(.flexible(minimum: 120, maximum: .infinity)), count: 3)
LazyVGrid(columns: column, alignment: .leading, spacing: 5) {
ForEach(data, id:…

skalber
- 467
- 4
- 14
2
votes
1 answer
SwiftUI: Custom label in navigation link is greyed out
I'm trying to use my custom card view as label to navigation link. this navigation link is also a Grid item.
The result is a
My Card Code:
struct CityCard: View {
var cityData: CityData
var body: some View {
VStack {
…

Omri Shapira
- 199
- 15
2
votes
1 answer
SwiftUI Thread 1: Fatal error: each layout item may only occur once
This little code is showing articles from an API with 2 columns with scrollview on ArticleView. Unfortunately after the 6th loadMoreContentIfNeeded it gives me hard time with this error
Thread 1: Fatal error: each layout item may only occur once
I…

Mert Köksal
- 817
- 1
- 7
- 26
2
votes
1 answer
SwiftUI LazyVGrid NavigationLink has unusual animation on return
I have a NavigationLink within a LazyVGrid and am getting this animation on return from the details view. Starting at about 3.5 seconds into that video, there is an animation I wasn't expecting. There are gaps introduced between the cells and I…

Chris Prince
- 7,288
- 2
- 48
- 66
2
votes
1 answer
LazyVGrid cell subviews keep disappearing for particular text inside cell
Scenario
I am trying to create a 3 columned LazyVGrid which displays items having an icon and a text via a LazyVGrid.
Code
struct CategoryPickerCellPresentationModel: Identifiable {
let id = UUID()
let name: String
let image: Image
…

G.Abhisek
- 1,034
- 11
- 44
2
votes
1 answer
SwiftUI & CoreData: How to count number of "true" booleans and display result in VGrid
I created a CoreData Entity called Event with its attributes category ( String) and isBlack (Bool). I also created a Button & a VGrid (Xcode 12 beta).
The button, upon clicked, adds and saves some entries to CoreData. I have a @FetchRequest and a…

Mike Z
- 105
- 7
2
votes
1 answer
Why does putting a view in a Button result in terrible lag on LazyVGrid (bug?)?
Here is my code. Without the button, but with an onTapGesture, the scrolling is buttery smooth. Great! But if I put the Text() view in a button, then the lag is really, really bad, hanging even a bit...
This is simplified code. In my actual project,…

Rillieux
- 587
- 9
- 23
2
votes
1 answer
SwiftUI - Constructing a LazyVGrid with expandable views
I'm trying to construct a two-column grid of quadratic views from an array of colors where one view expands to the size of four small views when clicked.
Javier from swiftui-lab.com gave me kind of a breakthrough with the idea of adding Color.clear…

Daniel_D
- 61
- 6
2
votes
1 answer
I can't get my LazyVGrid to show more than two rows
So I've got this very basic grid. It's 5 columns and should have 3 rows.
But I can't get the compiler to compile anything more than two rows....
The compiler complains : 'Extra arguments at positions #11, #12, #13, #14, #15 in call'
If I remove Text…

Tycho Pandelaar
- 7,367
- 8
- 44
- 70
1
vote
2 answers
How do I prevent an image from being squashed in a LazyVGrid cell?
I have a simple grid view where I have cells that show a square image with a couple of lines of text below it.
I'm trying to get the image to fill the square, clipped and not squashed in any way. I have got close, but the image seems to be…

Halpo
- 2,982
- 3
- 25
- 54
1
vote
0 answers
GeometryReader not working inside LazyVGrid
I have the following code
struct ContentView: View {
var items = ["1", "2", "3", "4"]
var body: some View {
LazyVGrid(columns: [GridItem(), GridItem()]) {
ForEach(items, id: \.self) { item in
…

Abdurakhmon
- 2,813
- 5
- 20
- 41
1
vote
2 answers
How to add Overlay to the Row of grid item
I want add Rounded Rectangle to the Entire row when user click any of the grid item from that row..how can i add that rectangle to entire row...
struct ContentView: View {
let data = [Date]
let columns = Array(repeating:…

user20935301
- 9
- 3
1
vote
0 answers
SwiftUI Photo Gallery View Smooth Scrolling
I'm building a photo gallery using SwiftUI, and am trying to ensure that a user can smoothly scroll through thousands of photo thumbnails without performance degradation or visible load times for each photo.
So far, my research has led me to use a…

Sean
- 64
- 2
1
vote
0 answers
.onTapGestrure for LazyVGrid item does't identify the right item
I have following LazyVGrid view in my code
LazyVGrid(columns: columns) {
ForEach(monthNames!, id: \.number) { month in
Text(month.name)
}
ForEach(balances, id: \.id) { balance in
Text(valueFormatter.string(from:…

Dawy
- 770
- 6
- 23