Category "swiftui"

Passing an ObservableObject model through another ObObject?

I feel like I can sort of understand why what I'm doing isn't working but I'm still trying to wrap my head around Combine and SwiftUI so any help here would be

SwiftUI Force Portrait On All Except One View

I have a SwiftUI project. For all but one of the views, I want to allow portrait and only portrait mode. For only one view, I want to allow both portrait and la

Is it correct to expect internal updates of a SwiftUI DynamicProperty property wrapper to trigger a view update?

I'm attempting to create a custom property wrapper supported by SwiftUI, meaning that changes to the corresponding properties values would cause an update to th

Binding ViewModel and TextFields with SwiftUI

I'm looking for the best way to create a bind between textfields and ViewModel. At the moment I'm creating a @State for each textfield and I'm manually sending

SwiftUI Button inside a NavigationLink

I have a view for a list item that displays some basic information about a task embedded within a navigationLink. I would like to use a button within the navi

How to limit the number of results in a FetchRequest in SwiftUI

How can I limit the size of the retrieved FetchedResults when making a FetchRequest to CoreData? struct ContentView: View { var fetchRequest:FetchRequest&l

Quickest way to dirty a FileReferenceDocument in SwiftUI for macOS

I have a number of changes to a document-based application which are not undoable (conceptually, think quiz progress) but which should dirty the document so the

SwiftUI picker .onChanged only firing on 2+ selection changes

I have a picker that will change an attribute of an object that is bound to the view. When the picker is changed I want to update the bound object so the change

How can I detect a right-click in SwiftUI?

I'm writing a simple Mines app to help me get to know SwiftUI. As such, I want primary click (usually LMB) to "dig" (reveal whether there's a mine there), and s

SwiftUI: How to only run code when the user stops typing in a TextField?

so I'm trying to make a search bar that doesn't run the code that displays the results until the user stops typing for 2 seconds (AKA it should reset a sort of

SwiftUI Can I use Binding get set custom binding with @Binding property wrapper?

How can I use Binding(get: { }, set: { }) custom binding with @Binding property on SwiftUI view. I have used this custom binding successfully with @State variab

SwiftUI DatePicker Binding optional Date, valid nil

I'm experimenting code from https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ my goal is to have DatePicker bind to Binding<

How do I set the minimum window size with swiftUI, and how do I make the window use the specified size and position when launching?

I am making a macOS app with swiftUI. I want to set the minimum size of the window to 800, 500. Also there is this thing that if I close the window, and reopen,

SwiftUI inputAccesoryView Implementation

I am trying to implement an inputAccessoryView on a TextField in SwiftUI. The goal is to have a "Done" Button appear above the Keyboard which when pressed gets

How to implement a left or right DragGesture() that trigger a switch case in SwiftUI?

I have created a DragGesture in a View that should select a @State(Bool) whether the user swipe left or right. The thing is that only swiping right is detecte

NavigationLink onTapGesture and navigation not firing consistently

In a SwiftUI view I implemented a vertically scrolling list by creating a VStack that contains a NavigationView that contains some text. I build this by loopin

(SwiftUI) How to search using IGDB api, search in api

I need help I have app I'm using IGDB api and displaying games with no issue. I need ability to make user search and send the user text to api to display the ga

How can I remove Textfield focus when I press return or click outside Textfield? (SwiftUI, MacOS)

How can I remove Textfield focus when I press return or click outside Textfield? Note that this is SwiftUI on MacOS. If I do this: import SwiftUI struct Cont

GeometryReader in SwiftUI ScrollView causes weird behaviour and random offset

Im trying to create a ScrollView that in turn contains a GeometryReader (Explicitly not the other way around). The GeometryReader should contain an (image) with

Multiple sheet(isPresented:) doesn't work in SwiftUI

I have this ContentView with two different modal views, so I'm using sheet(isPresented:) for both, but as it seems only the last one gets presented. How could I