Category "swiftui"

iOS Document Picker crashes when picking a PDF on a real device

I try to create a Document Picker for my iOS app. Here is my code (I wrapped the UIDocumentPickerViewController in my SwiftUI View, with UIViewControllerReprese

SwiftUI - How to deinit a StateObject when navigating back?

I want my @StateObject to be deinitialized as soon as possible after I navigate back, but it seems that the object is held in memory. "Deint ViewModel" is not b

SwiftUI ViewModifier for custom View

Is there a way to create a modifier to update a @State private var in the view being modified? I have a custom view that returns either a Text with a "dynamic"

Make List Sections non-collapsible in SwiftUI when embedded into a NavigationView SwiftUI

When I embed a List grouped into Sections into a NavigationView the section headers become collapsible. I'd like to keep them non-collapsible, just like when th

NavigationLink inside LazyVGrid cycles all entries on back, SwiftUI

I have an image grid. Each image on tap should push a view on the NavigationView with the image details. The navigation link works as intended, but when I press

SwiftUI Modal Inherits SearchBar during Sheet Presentation

Consider the following example with a list and a button wrapped in a HStack that opens up a sheet: struct ContentView: View { @State var text: String = ""

Simple SwiftUI Background Image keeps moving when keyboard appears

This is driving me nuts. There seems to be new behaviour for handling background images in iOS14. Desired effect is: a fixed background image that fills the scr

Fixing the size of a custom font in SwiftUI iOS 13+ when ignoring Dynamic Type

In an app I'm developing (SwiftUI for iOS13 and above), I have imported a custom font, and I load the font using the following method": func getDigitalXFontOfS

SwiftUI - fade out a ScrollView

I have a generated, oversized chart, which I put into a ScrollView so that the user can scroll to the right and see all values. I would like to indicate to the

Swift ui macOS popover on the button or on an image

I wish I could do such a thing as seen in the image. I'm trying to use this piece of code but I'm not quite understanding how to fix it. I wish I could use it

SwiftUI - fade out a ScrollView

I have a generated, oversized chart, which I put into a ScrollView so that the user can scroll to the right and see all values. I would like to indicate to the

3D artwork that is exported as USDZ has different colors

I want to start by saying that I am new to SceneKit and playing with AR environments on iOS. I have a 3D model object, a van, as part of a Blender file(.blend)

How do you share a data model between a UIKit view controller and a SwiftUI view that it presents?

My data model property is declared in my table view controller, and the SwiftUI view is modally presented. I'd like the presented Form input to manipulate the d

SwiftUI Word Wrap for multiline text Word Hyphenation Problem

I'm facing the following problem with SwiftUI Text: In the following example SwiftUI breaks the word "Amazement" into "amazeme" on the first line and "nt" on th

how to switch tab programmatically on button click? in swiftui

I have implemented tab bar in my code. I have see all button in my first tab and from that button i want to switch to second tab programmatically. When I use na

Limit rectangle to screen edge on drag gesture

I'm just getting started with SwiftUI and I was hoping for the best way to tackle the issue of keeping this rectangle in the bounds of a screen during a drag ge

How to make a SwiftUI DocumentGroup app without starting on the file picker?

If a user uses the Document App template in Xcode to create a SwiftUI app, macOS starts them off with a new document. This is good. I can work with that to pres

What does animatableData in SwiftUI do?

I was playing around with the animatableData property for a custom Shape I made but I couldn't really visualise what it does and where the system uses it. I did

SwiftUI custom list with ForEach delete animation not working

I am creating a custom list displaying time information (minutes and seconds, not used in the snippet below to simplify the code). I managed to implement a nice

How does one use NavigationLink isActive binding when working with List in SwiftUI?

The use case is pretty simple. I have a List of places, and each corresponds to a geofence. I need to enable navigation in that particular row(s) whose geofence