Questions tagged [lazyvgrid]
39 questions
1
vote
1 answer
How to drag across Views in a LazyVGrid with GeometryReader?
I want to drag across rectangles in a grid and change their color. This code is almost working, but this is not always the right rectangle that reacts: it behaves rather randomly. Any hints?
import SwiftUI
struct ContentView: View {
let data =…
![](../../users/profiles/3338488.webp)
user3338488
- 61
- 6
1
vote
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…
![](../../users/profiles/1675875.webp)
Chris Prince
- 6,390
- 1
- 38
- 56
1
vote
1 answer
SwiftUI - contextMenu on LazyVGrid cell causing animation crash when Map present
I have a LazyVGrid and a NavigationBarItem button that changes the number of columns. It cycles through 1, 2, 3 then back to 1, etc. I use the .animation(.default) modifier to animate this change. When there is just one column I use a different cell…
![](../../users/profiles/3306020.webp)
Magnas
- 3,507
- 4
- 27
- 40
1
vote
0 answers
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,…
![](../../users/profiles/3762119.webp)
Rillieux
- 267
- 3
- 15
1
vote
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…
![](../../users/profiles/10603026.webp)
Daniel_D
- 51
- 5
1
vote
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…
![](../../users/profiles/224571.webp)
Tycho Pandelaar
- 6,500
- 6
- 36
- 66
0
votes
1 answer
Preview crashed after added LazyVGrid
I am learning Stanford CS193p, and everything went so well till switching LazyVGrid with HStack.
I checked my code with the one professor made, they are the same. But the confusing part of my code is that, when my emojiCount = 4, preview worked…
![](../../users/profiles/14898982.webp)
YephooShaw
- 3
- 2
0
votes
0 answers
SwiftUI: LazyVGrid not spacing properly
I am following Apple's WWDC2020 SwiftUI video "What's new in SwiftUI"
This one: https://developer.apple.com/videos/play/wwdc2020/10041/
I have opened this video in Apple's "Apple Developer" App, which provides the demo code.
I just copied this…
![](../../users/profiles/14119170.webp)
user14119170
- 41
- 7
0
votes
0 answers
Why does my SwiftUI Grid not adapt to the space available?
Why does my SwiftUI Grid not adapt to the space available? And how can I fix it?
I tried to follow and modify the code from Apple's WWDC video "Stacks, Grids, and Outlines in SwiftUI".
import SwiftUI
struct ContentView: View {
var body: some…
![](../../users/profiles/14119170.webp)
user14119170
- 41
- 7
0
votes
1 answer
EditButton() in SwiftUI inside a ScrollView / LazyVGrid
It seems like the EditButton() in SwiftUI (Xcode 12.5 beta 3) has various issues.
In my code, everything was working fine until I replaced the List with a ScrollView and added a LazyVGrid. Now, when a user taps on the EditButton, EditMode is not…
![](../../users/profiles/10071648.webp)
FPL
- 361
- 2
- 16
0
votes
0 answers
SwiftUI LazyVGrid lags with images
When I scroll my LazyVGrid, app lags a lot.
LazyVGrid(
columns: [
GridItem(.adaptive(minimum: horizontalSizeClass == .compact ? 160:320, maximum: 320), spacing: 16, alignment: .top)
],spacing: 16
){
ForEach(viewModel.articles){…
![](../../users/profiles/15513485.webp)
Dev
- 1
- 1
0
votes
1 answer
matchedGeometryEffect on ScrollView memory leaks
Im using a LazyVGrid to show an article gallery.
Everything is working fine, and I have no memory warnings, because every time a view leaves screen, memory usage is reduced.
My problem is when I use matchedGeometryEffect with the image, in order to…
![](../../users/profiles/15513485.webp)
Dev
- 1
- 1
0
votes
0 answers
SwiftUI LazyVGrid dynamic row height
I would like to have a LazyVGrid of rows with same heights expanding/shrinking to fill the available parent height
Is it possible?
let columns = Array(repeating: GridItem(.flexible(minimum: 50, maximum: 100)), count: 3)
LazyVGrid(columns: columns,…
![](../../users/profiles/6725196.webp)
Simon Borkin
- 1
- 1
- 3
0
votes
1 answer
Dismiss a View in SwiftUI when parent is re-rendered
Using iOS14.4, Swift5.3.2, XCode12.2,
I try to dismiss a SwiftUI's GridView (see below code).
The dismiss function is done by the \.presentationMode property of the @Environment as explained here.
Everything works until the moment where I introduced…
![](../../users/profiles/3826232.webp)
iKK
- 4,553
- 5
- 45
- 93
0
votes
1 answer
Add multiple LazyVGrid to ScrollView
I have an app that displays collections of thumbnails by days, each day is its own LazyVGrid and all days are bunched up in a VStack.
Bottom line, it looks like adding multiple LazyVGrid in a single ScrollView almost works... but doesn't.
It causes…
![](../../users/profiles/318858.webp)
Yann Bizeul
- 185
- 1
- 8