54 questions
0
votes
1
answer
144
views
Buggy ScrollView + LazyVStack animation - is it fixable?
The following code will render a list of items and a button to shuffle them and change their height withAnimation.
If you scroll down and shuffle it you will eventually see glitches in the animation, ...
0
votes
1
answer
233
views
Multiple pinned views at the top of a LazyVStack within a ScrollView
I am trying to create a ScrollView with a LazyVStack where two headers are pinned at the top. It should also work within a NavigationStack using large display mode for the title. Both headers should ...
1
vote
0
answers
68
views
How can I scroll a ScrollView to a view nested arbitrarily deeply in a LazyVStack?
I want to set the scroll position of a ScrollView containing a LazyVStack such that it shows a view nested arbitrarily deeply within that stack.
Currently I give the view which should be scrolled to ...
0
votes
1
answer
496
views
Double sticky header in SwiftUI
Here's a full code example of an attempt at a double sticky header view:
struct ContentView: View {
var body: some View {
ScrollView(showsIndicators: false) {
LazyVStack(...
0
votes
0
answers
74
views
Why does LazyVStack footer stutter when section height exceeds screen frame in SwiftUI?
I am having some issues with sticky footers on PinnedScrollableViews in SwiftUI for iOS. I am working on a LazyVStack embedded in a ScrollView with footers on each section of the LazyVStack. The size ...
1
vote
2
answers
269
views
Why doesn't LazyVStack release memory when scrolling
I have a `PhotosPicker` that selects an image. Then, upon pressing the "Save" button, I save it in `FileManager` and store its path in `CoreData`. When I need to retrieve them, I use a `...
0
votes
1
answer
171
views
Update on Parent View list from Child view using SwiftData
My problem is with SwiftData not updating the object which is used with @Query. here are my code
This is my View which used to show list of books,
struct ReadingView: View {
@Environment(\....
0
votes
0
answers
397
views
SwiftUI ScrollView has weird behavior when reseting the content
I'm working with SwiftUI and trying to do a ScrollView that can be filtered (it's basically a list).
The stack looks like this:
class ViewModel: ObservableObject {
@Published
var isRefreshing =...
1
vote
0
answers
217
views
How do I write my own SwiftUI ScrollView that will respect a lazy subview?
I am trying to write my own MyScrollView to manage scroll. I am doing this because I want to have a LazyVStack with items that have varying heights and for which I can scroll to any item inside. So, ...
1
vote
0
answers
220
views
SwiftUI - zIndex change not working for item inside of LazyVStack
I have problem with zIndex in my app with collection of images
I've added pinch zoom to the image, but when image is zoomed it does not get on top of other images which are next in the collection.
...
3
votes
1
answer
1k
views
Keyboard is immediately hidden when focus TextField in LazyVStack (SwiftUI)
I have a stack of cards, each card having a TextField, when focus a text field positioned at the bottom of the screen (on the area where the keyboard will appear) the card disappears, thus the ...
2
votes
1
answer
2k
views
SwiftUI ScrollViewReader scrollTo doesn't fully scroll to element when using LazyVStack with pinned sectionHeaders
I'm trying to create sticky header with manual scroll to functionality (eg. categories bar allowing user to move to chosen section). I have issues with one part of that functionallity. While ...
1
vote
1
answer
764
views
Get current item in LazyVstack inside scrollview when scroll ends
I want to print the currently displayed item in LazyVStack which is inside scrollview with paging enabled.
i have tried printing in onAppear of VerseView
The issues with printing inside onAppear are-
...
3
votes
3
answers
1k
views
scroll indicator incosistent and stutters with LazyVStack
I use LazyVStack because I need to load a big list of elements, LazyVStack helps with loading fewer elements, hence the scroll bar/indicator does not know the real size of the list, causing ...
0
votes
0
answers
213
views
SwiftUI: ViewModifier together with id() on a cell causes ScrollView performance issues
There is very poor performance when pulling scroll bar indicator to bottom and scrolling cells with big ordinal numbers. But if we comment empty ViewModifier applied to cell, everything became ok.
...
0
votes
1
answer
253
views
videoplayer inswiftui view not using fullscreen
I am building an app with a feed of videos which looks like TikTok or Facebook Reels, in a sense that I want one post using fullscreen so the video use the entire space.
It seems not working, and only ...
3
votes
2
answers
2k
views
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 ...
0
votes
0
answers
492
views
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 ...
3
votes
1
answer
971
views
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 ...
3
votes
1
answer
814
views
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....
1
vote
2
answers
4k
views
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, ...
0
votes
0
answers
268
views
LazyVstack inside TabView
LazyVstack insde TabView wrapped on scrollView not working (performance issue)
var body: some View {
ScrollView {
Text("hello, world!")
TabView(selection: $tab) {
...
0
votes
1
answer
830
views
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 ...
2
votes
1
answer
748
views
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 ...
6
votes
3
answers
4k
views
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 ...
1
vote
1
answer
837
views
How to bring an Image to foreground in LazyVStack/ScrollView SwiftUI?
I have a LazyVStack of Post Views with images in those views (similar to Instagram). When I'm zooming in on one of the images, I would like for that image to overlap over all other content. However, ...
0
votes
1
answer
865
views
How does LazyVStack choose to re-render if Identifiable is constant?
How does a LazyVStack in SwiftUI decide if it needs to re-render a View, assuming the Identifiable property of an item it is rendering does not change?
This trivial demo code below, I feel, should not ...
2
votes
2
answers
1k
views
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 ...
2
votes
1
answer
673
views
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 ...
3
votes
2
answers
3k
views
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 (...
1
vote
1
answer
4k
views
SwiftUI - LazyVStack inside ScrollView gives unexpected behaviour
I'm building a chat app using SwiftUI and I'm having difficulties getting a LazyVStack to work inside a ScrollView. Here are my questions:
Question 1
Where I have .id(message.id), why is this id ...
1
vote
1
answer
871
views
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 ...
0
votes
1
answer
376
views
Break a LazyVGrid into pieces
I have the following grid made in SwiftUI with this code:
let columnGrid = [GridItem(.fixed(boxWidth), spacing: 0),
GridItem(.fixed(boxWidth), spacing: 0),
...
12
votes
1
answer
5k
views
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/...
0
votes
0
answers
1k
views
How do I properly display very large images in a SwiftUI LazyVStack
I have a LazyVStack in a scrollView with many images. The size of the images in the scrollView is quite small, about 300x300 points. The images are extracted from Data stored in CoreData. The ...
9
votes
4
answers
12k
views
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 ...
-1
votes
1
answer
3k
views
How to detect that LazyVGrid's items get re-built?
In my app, LazyVGrid re-builds its contents multiple times. The number of items in the grid may vary or remain the same. Each time a particular item must be scrolled into view programmatically.
When ...
5
votes
1
answer
2k
views
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 ...
0
votes
0
answers
638
views
SwiftUI Where exactly to use Lazy Stacks for performance optimization?
A lot of sites online that demonstrate using a Lazy stack to load a lot of views use e.g. ForEach(1...100, id: \.self) { value in to demonstrate usage. But in a production app with complex views I ...
3
votes
5
answers
4k
views
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
...
4
votes
0
answers
655
views
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 ...
1
vote
2
answers
767
views
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 ...
4
votes
2
answers
3k
views
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 ...
2
votes
1
answer
720
views
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: {
...
2
votes
0
answers
226
views
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 ...
7
votes
0
answers
3k
views
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 ...
1
vote
1
answer
656
views
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 {
...
1
vote
1
answer
2k
views
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 ...
1
vote
0
answers
1k
views
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 ...
1
vote
0
answers
447
views
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 ...