Questions tagged [lazyvstack]

LazyVStack is a SwiftUI element introduced in SwiftUI 2.

For more information, see the official documentation of LazyVStack.

40 questions
11
votes
0 answers

why is the swiftUI list not lazy (compared to lazyVStack)?

are lists in SwiftUI really lazy? I am having a list of 5000 elements fetched from coreData and I want to display them in a list. I read a lot of comments (like that: https://developer.apple.com/forums/thread/651256) that Lists are lazy but for me…
printDavid
  • 165
  • 1
  • 9
5
votes
3 answers

How to set a custom prefetching time for LazyVStack in SwiftUI?

TL;DR: Is there some parameter or way to set the offset at which LazyVStack initialises views? LazyVStack initialises the views lazily, so when I scroll, the next (few?) views are initialised. I am loading an image once a view is drawn, using…
D. Kee
  • 169
  • 14
5
votes
4 answers

SwiftUI: Add refreshable to LazyVStack?

When I use a List view I can easily add the refreshable modifier to trigger refresh logic. My question is how to achieve the same when using a LazyVStack instead. I have the following code: struct TestListView: View { var body: some View { …
zumzum
  • 17,984
  • 26
  • 111
  • 172
5
votes
1 answer

LazyVStack Initializes all views when one changes SwiftUI

I have a LazyVStack which I would like to only update one view and not have all others on screen reload. With more complex cells this causes a big performance hit. I have included sample code import SwiftUI struct ContentView: View { @State…
Jacob Zyla
  • 225
  • 2
  • 11
5
votes
0 answers

ScrollView + LazyStacks stutter

I've had many similar issues to this when using ScrollViewand LazyVStack/ LazyHStack where the content of the lazy stack will stutter upon bouncing on the edge of the ScrollView. First I thought it might be due to using complex Views on the lazy…
3
votes
2 answers

List of SwiftUI very slow when scrolling with realtime data

I have a List and about 1000 item in an Array, and my items update in realtime (100 updates/s). My List is very non-performant. This my test code (I tried with List and LazyVStack): struct PriceBoardView2 : View { @EnvironmentObject var…
2
votes
1 answer

SwiftUI - confirmationDialog has abnormal behavior when inside a LazyVStack

I have a ScrollView with a LazyVStack which holds n subviews. Each subview has a button which will present a confirmation dialog, the confirmation dialog is created inside the child. the confirmation dialog for some reason doesn't work after seeing…
Javier Heisecke
  • 1,162
  • 1
  • 11
  • 28
2
votes
1 answer

SectionedFetchRequest with LazyVStack/ForEach Fails to Update Properly

(Modified title and added Contact List example with code and behavior differences between Lists and LazyVStack/ForEach.) Within a NavigationView/LazyVStack, mutually-exclusive ForEach loops group query results that come from a @FetchRequest. When an…
SwiftAero
  • 69
  • 4
2
votes
1 answer

How to align ScrollView content to top when both axes are used?

Here's a simple example: struct Example: View { var body: some View { ScrollView([.horizontal, .vertical], showsIndicators: false, content: { LazyVStack(content: { ForEach(1...10, id: \.self) { count in …
Randex
  • 770
  • 7
  • 30
2
votes
0 answers

Detecting screen interaction outside of the component in SwiftUI

I'm building my own custom list using LazyVStack with swipeable actions thanks to this tutorial: https://prafullkumar77.medium.com/swiftui-how-to-make-custom-swipe-able-cell-727a27abdddd It isn't half bad as long as you read through it and…
Beau
  • 43
  • 7
1
vote
0 answers

How to create multiple pinned views below each other in SwiftUI?

I'm trying to create a multiple layered scrollView with each layer being pinned when scrolling through the list. Currently, the pinnedViews are pinned on top of each other when scrolling to the bottom. See screenshots for current and desired…
1
vote
2 answers

SwiftUI List animations are not smooth when adding elements to a VStack in a List row

I am using a List in my app with some rows containing VStacks. I'm using a list and not a LazyVStack inside a ScrollView because I want to leverage some of the List features such as moving rows, swipe, etc. When I try to add elements to a VStack in…
alionthego
  • 8,508
  • 9
  • 52
  • 125
1
vote
1 answer

SwiftUI 4: ViewThatFits doesn't choose the right view if it's inside a LazyVStack

I followed ViewThatFits tutorial mentioned here, to show and hide a text according to its length and the available space as follows: struct ExpandableText: View { let text: String let initialLineLimit: Int @State private var isExpanded =…
JAHelia
  • 6,934
  • 17
  • 74
  • 134
1
vote
2 answers

SwiftUI - LazyVStack displaying more elements in view than required

I've been following a youtube tutorial for using LazyVStacks. https://www.youtube.com/watch?v=o6D7mUXjSmI When I run the same code as per the tutorial, the LazyVStack using Xcode Version 13.2.1 (13C100) on a iPhone 11 Pro Max (running iOS 15.2)…
Vaz
  • 309
  • 2
  • 15
1
vote
1 answer

SwiftUI VStack cell onTap acting strange

I have a bunch of cells in a vertical scroll view, but am seeing some weird behavior from the onTapGesture and fullScreenCover for those cells. When I click on a cell, it registers the correct cell in onTapGesture but presents the wrong object, in…
Noah Iarrobino
  • 1,435
  • 1
  • 10
  • 31
1
2 3