209 questions
2
votes
1
answer
4k
views
swiftui ScrollViewReader scrollTo not correct working
I am developing an application with swiftui. After zooming, when I say scroll to the corner with the ScrollViewReader, it goes out of the screen. my code is below. It fails after trying a few times. ...
2
votes
3
answers
3k
views
SwiftUI - how to make horizontally scrollable views RTL friendly?
I have a SwiftUI app which supports both LTR and RTL languages. It is not fixated to either one of those, it just depends on what user wants.
I have a horizontally scrollable list of things inside a ...
1
vote
1
answer
936
views
Scroll to bottom of a list populated with CoreData in SwiftUI
I'm trying to scroll to the bottom of List when a button is tapped. I have tried placing the List in a ScrollViewReader and this seems to work only when the List is populated using an array. When I ...
2
votes
2
answers
2k
views
SwiftUI - How to get ScrollView Content Height after once the inside content is changed in Run time
I am able to print scrollview content height based on the below code when the countvalue is static
struct ContentView: View {
@State var countValue : Int = 1000
var body: some View {
...
1
vote
1
answer
245
views
Center Scroll View content
I have centered my Scroll View by using GeometryReader like this:
struct ContentView: View {
var body: some View {
NavigationView {
GeometryReader { geom in
...
5
votes
6
answers
6k
views
SwiftUI: ScrollView that drags bottom sheet with it
I'm trying to create a SwiftUI Scrollview that drags its container like this: https://drive.google.com/file/d/1O92DgsVI1OjM1HEUXUwVywB8gcdShOP-/view?usp=sharing
Many Apple apps use this (Apple Maps, ...
1
vote
1
answer
957
views
SwiftUI: Adjust bounds of ScrollView
I am trying to scale a view horizontally using scaleEffect and MagnificationGesture.
It is almost working as I want with the exception that the ScrollView does not resize when its child view resizes.
...
0
votes
1
answer
601
views
SwiftUI/UIKit: Horizontal ScrollView to scale view
I am trying to zoom a view horizontally using UIScrollView.
My code almost gives me what I want except that it also scales the view vertically.
What I want to achieve is that the image only gets ...
3
votes
0
answers
2k
views
How to make ScrollView refreshable swiftui?
With Swiftui 3 Apple added modifier refreshable. I can use it with List. But if I have scrollview it doesn't work. Any ideas?
ScrollView(.vertical) {
LazyVGrid(columns: columns, spacing: ...
5
votes
1
answer
1k
views
How do I modify the background color and shape of drag&drop preview SwiftUI?
I'm trying to implement simple list with draggable cells (iOS 15). For now I have two base solutions: List and ScrollView. None of this methods doesn't lead me to appropriate result.
First of all I'll ...
4
votes
0
answers
1k
views
SwiftUI How to automatically scroll ScrollView with expanding TextField?
I am working on a feature for my app which will allow user to dictate text which will appear in a textField. For that I created a scrollView with only a textField which contents are automatically ...
3
votes
0
answers
2k
views
SwiftUI iOS 14/15 Can't tap Button underneath Spacer in ScrollView
In SwiftUI, I have a Button that's underneath the Spacer within a ScrollView. The ScrollView steals the tap gesture, so the Button never sees the tap.
So, for example, the button in this example does ...
4
votes
2
answers
3k
views
SwiftUI - Calculate height for long GeometryReader inside ScrollView
Based off of this question: SwiftUI - Drawing (curved) paths between views
I draw the needed views and paths using the GeometryReader. The problem is, now it becomes too long for the screen to show it ...
3
votes
1
answer
3k
views
SwiftUI How can I center content in a dynamic horizontal scroll view when the total content width is less than screen width
I have a horizontal scrollView which shows a bunch of images from a dynamic image array. When the total content width is greater than the screen width everything is fine. However if say there is ...
13
votes
4
answers
4k
views
ScrollViewReader scrollTo with .center anchor bug?
So I'm try to use ScrollViewReader to programmatically scroll a horizontal scroll view. I thought it would work like scrollToItem with .centeredHorizontally in UIKit, and for the most part it does, ...
5
votes
0
answers
282
views
SwiftUI 2.0 Keyboard Avoidance set ScrollBar offset
I'd like to change the ScrollBar offset when tapping on a TextField in a ScrollBar which is located at the bottom (so keyboard avoidance will trigger).
When I select a TextField, the ScrollBar adjusts....
0
votes
0
answers
1k
views
Getting rid of SwiftUI ScrollView top padding
I just can't seem to get rid of the ~6 height padding(?) at the top of ScrollView. I've tried setting padding to 0 on both the ScrollView itself and on it's content. I've tried using SwiftUI-...
3
votes
0
answers
342
views
SwiftUI Disabling Keyboard Avoidance for item below a ScrollView in a VStack
I'm having some issues surrounding disabling keyboard avoidance in SwiftUI. My app has a custom tab bar which sits in a VStack underneath the content of the root view. However, most of my views have ...
2
votes
1
answer
8k
views
SwiftUI set max height on ScrollView
I have built a Chips Container based on this link. Basically is just a container that orders chips in rows. This is my code:
struct ChipsContent: View {
@ObservedObject var viewModel = ...
1
vote
2
answers
444
views
How to build scrollable side menu using text rotation (or something similar) in SwiftUI?
I want to build a menu like the image bellow where I can scroll between menus. I did try multiple combinations with HStack/VStack in ScrollView and rotation modifier on Text and/or stacks. However, ...
4
votes
1
answer
3k
views
Resetting ScrollView position to the top of the page
I'm trying to make the scroll reset to the top of the page when a view appears (e.g. when you navigate back from a navigation link). The ScrollView is embedded within a NavigationView with a large ...
1
vote
2
answers
5k
views
SwiftUI View scrolls horizontal and vertical as well, instead of scrolling only vertically
I am building an app as a learning project. I ran into a problem, where one of my tabs scrolls vertically and horizontally for no reason.
There is no content outside the safe-area, and i can´t think ...
2
votes
0
answers
521
views
ScrollViewReader anchor center creates free space
I want to zoom in on a specific element in the scrollview. I want it to be an anchor center. When zooming to the upper left elements, no problem, it works properly. But when you zoom in on the top ...
0
votes
1
answer
1k
views
SwiftUI Full Screen Width Content Within Form
How can I have a Form with one element in the Form taking up the full screen width?
I tried putting the Form into a ScrollView but then there are other issues and it might not be a good idea to nest 2 ...
0
votes
1
answer
824
views
Embedding webview within a tabview in SwiftUI
I've been trying to create a TabView with PageIndexViewStyle where each page is a ScrollView that contains an image and a WebView. The example code here from @Asperi works great when I'm creating a ...
0
votes
1
answer
2k
views
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 ...
3
votes
1
answer
891
views
How do I fix buttons not being tappable in a ForEach loop?
I have a view which contains a button. The view with the button is created from a forEach loop. For some reason only some buttons are tappable and others are not.
The parent view contains a ...
1
vote
1
answer
263
views
Swiftui ScrollViewreader multiple ScrollTo in different Foreach
I can't make many .scrollTo() in my code: (I'm French sorry for my bad english)
else if index == 1 {
withAnimation {
value.scrollTo(topID)
}
}
my issue is in value.scrollTo(topID)...
8
votes
0
answers
1k
views
SwiftUI ScrollView scrolls too far when using scrollViewReader
I'm creating an app where I'm presenting data in paged views and each view contains a vertical scrollable list, enabled by scrollView. I'm also using scrollViewReader to be able to programmatically ...
79
votes
7
answers
27k
views
Putting a LazyVStack or LazyHStack in a ScrollView causes stuttering
Xcode Version 12.4 (12D4e)
I have encountered this every time I have implemented a Lazy stack within a ScrollView:
Add a LazyHStack to a horizontal ScrollView or a LazyVStack to a vertical ScrollView
...
10
votes
0
answers
2k
views
How to use TabView or ScrollView for carousel?
I'm trying to create a carousel like some of Apple's apps. The TabView has the paged style but it doesn't "peek" at the previous and next elements. The ScrollView(.horizontal) doesn't snap. ...
2
votes
1
answer
580
views
SwiftUI tap under scrollview
Tap gesture on green does not work. Does anyone have a solution for this?
ZStack {
Color.green
.onTapGesture {
print("green")
}
ScrollView {
...
3
votes
0
answers
932
views
SwiftUI Calendar on scroll get current month
Im trying to get the current month when the calendar is being scrolled. My goal is to have the header with the current month, then when the view is scrolled down to a new month the header updates ...
1
vote
1
answer
3k
views
In SwiftUI, how to scale content inside scrollView with dynamic changing scrolling area?
I'm developing MacOS App with SwiftUI.
Let's say we have a fixed size window, which will show a scrollable image.
Now I want to create a feature which can let user to scale the image, and can scroll ...
2
votes
1
answer
681
views
Button click triggers although clicking on button below
I have following code. Two big buttons at the top and a ScrollView with many buttons below:
struct ContentView: View {
var body: some View {
VStack (spacing: 0) {
HStack (...
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 ...
2
votes
1
answer
969
views
NavigationLink inside LazyVGrid is not displayed correctly in swiftUI macOS
I am developing a cross platform app in SwifUI. On iPhone / iPad this code works really well on MacOS instead when I insert a NavigationLink the ForecastCardView is totally cut off. When I remove the ...
0
votes
1
answer
504
views
SwiftUI Horizontal ScrollView item becomes invisible when scroll in iOS 14.3 but works fine in iOS 13
SwiftUI Horizontal ScrollView item becomes invisible when scrolled in iOS 14.3 but works fine in iOS 13
GeometryReader { geometry in
ZStack (alignment: .center) {
...
1
vote
0
answers
2k
views
Swiftui: check if content fits scrollview without scrolling
I wonder how to determine if the content inside ScrollView is fully visible without scrolling?
ScrollView {
LazyVStack {
PlainButton("1")
PlainButton("2")
PlainButton("...
4
votes
1
answer
8k
views
Save ScrollViews position and scroll back to it later (offset to position)
I have found a way to save a ScrollViews offset with a GeometryReader and a PreferenceKey.
SwiftUI | Get current scroll position from ScrollView
And the ScrollViewReader has a method scrollTo to ...
2
votes
2
answers
1k
views
Placing a rectangle in front of ScrollView affects scrolling
I need to place a translucent rectangle on front of ScrollView but when i put everything (Rectangle & ScrollView) inside of a ZStack, scroll & touch events stop working within this rectangle.
...
0
votes
0
answers
118
views
SwiftUI View scrollTo behaves differently second time presented
I have a SwiftUI modal view that consists of a scroll view, and implements the scrollTo functionality perfectly the first time it is presented.
The functionality breaks all subsequent times it is ...
1
vote
0
answers
246
views
SwiftUI macOS ScrollView crashes when HStack spacing is negative
I am using the following code to create a horizontal scroll view with negative spacing (I'm using negative spacing so the items in the stack overlap). Whenever my app is in a small window and I ...
2
votes
1
answer
1k
views
SwiftUI add border to onSelect horizontal Scrollview image
I tried to make a horizontal scrollview that contained a list of item. when I clicked any of the item, it will show a border(highlight) behind the item. When I press another item, the previous border ...
0
votes
0
answers
372
views
How do I add a zoomable SVG to SwiftUI?
I have a map that I want to put into my app, and I am currently learning SwiftUI. I want to put in an SVG where I can scroll, zoom, set initial x & y coordinates / initial zoom, max zoom, and tap ...
1
vote
1
answer
425
views
How can I read Drag location in ScrollView in SwiftUI?
I am trying to read location in DragGesture of a View connected to a ScrollView, but ScrollView take control of DragGesture on all view and does not let me to read those information.
Here is my ...
0
votes
1
answer
226
views
Combining and Breaking a Vertical scrollView Horizontally in SwiftUi?
does anyone have an idea how can i break Vertical ScrollView into small horizontal ScrollView using SwiftUi:
I have the code bellow which displays the youtubeResults vertically, since each item of ...
4
votes
2
answers
2k
views
SwiftUI: horizontal ScrollView inside NavigationLink breaks navigation
I want to use a simple horizontal ScrollView as NavigationLink inside a List. However, tapping on the ScrollView is not registered by a NavigationLink and therefore does not navigate to the ...
2
votes
1
answer
6k
views
Content offset in ScrollView SwiftUI
I built a simple horizontal calendar with SwiftUI and it works fine. But I want that it automatically scroll to the current date at app launch. How can I do this? I assume I should use GeometryReader ...
0
votes
1
answer
3k
views
Cannot convert value of type 'TaskElement' to expected argument type 'EnvironmentObject<TaskElement>'
I have set my TaskElement model to be an environmentObject to be able to edit tasks. I did like this to be able to edit tasks on the same page to create a new task. Which is called NewTaskView. Btw, I ...