Questions tagged [lazyvstack]

LazyVStack is a SwiftUI element introduced in SwiftUI 2.

For more information, see the official documentation of LazyVStack.

40 questions
1
vote
4 answers

LazyVStack - row onAppear is called early

I have a LazyVStack, with lots of rows. Code: struct ContentView: View { var body: some View { ScrollView { LazyVStack { ForEach(0 ..< 100) { i in Text("Item: \(i + 1)") …
George
  • 25,988
  • 10
  • 79
  • 133
1
vote
0 answers

SwiftUI LazyVStack child disappears when scrolling

I have a simple LazyVStack with a custom view. I noticed that when it is scrolled under the navigation bar the view disappears prematurely. Is there a good work around of this besides to disable scrolling when it is not needed? I have attached an…
Scott Andrew
  • 41
  • 1
  • 6
1
vote
2 answers

SwiftUI: Index out of range when last element gets removed

I have a checklist made with LazyVStack, I implemented remove functionality for the checklist items, but for some reason the app crashes with "Index out of range" only when I try to remove the last element Here is my code: struct ChecklistView: View…
Hussein
  • 487
  • 6
  • 22
1
vote
1 answer

SwiftUI - change Model from nested subviews

I have a LazyVStack presenting Cells. My main View which has the LazyVStack has a viewModel. @StateObject private var model = ViewModel() The Stack presents a list of CustomViews. LazyVStack { ForEach(model.items) { item in …
PoolHallJunkie
  • 1,345
  • 14
  • 33
1
vote
1 answer

How can I get the current index(id) of last visible row in a List or LazyVStack after the user scrolls and reference it after rotation?

I have a LazyVStack in my UI and after device rotation the rows showing are not the same as prior to rotation. Not even close to those rows. Prior to SwiftUI I was handling this by getting the last visible row in viewWillTransition and then…
alionthego
  • 8,508
  • 9
  • 52
  • 125
1
vote
0 answers

Reorder SwiftUI List in Mac App with LazyVStack

Here is a simple macOS demo app that compares using a SwiftUI List and a LazyVStack. I prefer to use a LazyVStack because it's easier to customize the style. But it seems some of the built-in functionality is missing, such as reordering list items…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
1
vote
0 answers

Nested ForEach + ScrollView Header causes Glitches

Inside of a Scrollview I use a LazyVStack with a pinned header, and based on the scroll position I manipulate the scale of that header. In the LazyVStack, I have a ForEach iterating over some list of items. However, if I use a nested ForEach loop…
bze12
  • 727
  • 8
  • 20
1
vote
0 answers

SwiftUI: How Can I delete an Item / Check an Item Off of a to-do List When using a LazyVStack rather than a List?

enter image description here Let me begin by saying that I am quite new to programming, I have little to no experience. I need to make a to-do list for a school project and really need help. I am trying to make a to-do list with a more aesthetic…
1
vote
2 answers

LazyVStack scrolling stops animations

This code lists 100 rows with refresh icon animations. When using a LazyVStack instead of a VStack, after scrolling down to the bottom of this list all the animations stop, including those at the top of the list once you scroll back. No such…
andrewz
  • 4,729
  • 5
  • 49
  • 67
0
votes
2 answers

Swift UI LazyVStack with nested VStack

I'm experiencing this issue and not user if it's a swift ui bug or expected behaviour. Could not find something related to this online. Given this view struct ContentView: View { var body: some View { ScrollView(.vertical) { LazyVStack…
Daniel
  • 1,225
  • 2
  • 15
  • 31
0
votes
0 answers

fullScreenCover is being dismissed when rotating view

I have a manga series detail view that displays the series information and all of the chapters. Each chapter you can tap on to read and it will present the reader with a fullScreenCover. When rotating the reader to any orientation it dismisses back…
0
votes
1 answer

Image in LazyVStack using massive memory

I make a simple app for displaying image list. I use a LazyVStack inside ScrollView as container, ForEach to load every image Images are loading from network, I have tried AsyncImage, but AsyncImage always loads image from network and no cache. I…
yww
  • 21
  • 3
0
votes
0 answers

LazyVstack inside TabView

LazyVstack insde TabView wrapped on scrollView not working (performance issue) var body: some View { ScrollView { Text("hello, world!") TabView(selection: $tab) { p1().tag(0) P2().tag(1) } …
0
votes
0 answers

Bug with LazyVStack in SwiftUI

I have code with SwiftUI, but when I use LazyVStack to optimize performance, my app has a bug, is when I scroll to bottom, and load more data, LazyVStack will don't continue generate View to Screen: example video :…
0
votes
1 answer

How do I align multiple columns in a LazyVStack?

I am trying to make a grid which has multiple columns using a lazyvstack. I want the items to align perfectly, regardless of its length. This is what I want: However, with my code down below, I am getting this: . let events = [["1234567890",…
Gura
  • 5
  • 2