Category "swiftui"

Updating @Published var if a userdefault value is present swift

I am trying to check my app and see if a value exists in user defaults and if it does exist they will be taken into the app. If it doesnt exist they need to ent

SwiftUI Picker not changing bounded value - is binding ok?

I have a view with @State var myTask:MyTask let priorities = ["","A","B","C","D","E","F","G","H","I","J","K"] var body: some View{ VStack{ Picke

Is there a way to check if @Environmentobject exists swiftui

I have a view hierarchy where sometimes there is a chance that an @EnvironmentObject is not resolved. Is there a way to check if such @EnvironmentObject exists

Get coordinates in real time of a moving view in SwiftUI

I am moving a view called Point (which is basically a point), the point is moving in the screen every 2 seconds, and I need to update the coordinates in real ti

Why is there a Gap between VStacks in SwiftUI?

A whiteness is seen in the area drawn with the red line. If I change the background color of the most inclusive Vstack, that white area changes. Deleting spacer

Change the mapType to .satellite etc with a picker

I want to be able to change the mapType from .standard to .satellite and .hybrid in xCode 13.3 Can anybody tell me if it is at all possible with this code? I im

SwiftUI - proper use of @available() and #available

Am I missing something in the following code? This app builds (macOS Monterey b5 / Xcode 13 b5) and executes perfectly on an iOS 15 device -- but causes a SIGAB

Long Press Gesture Recognizer location(in: view) not correctly calculating location

I'm using a UIScrollView to display an image with various markers on top. The image view has a UILongPressGestureRecognizer that detects long presses. When the

How to convert value of optional type Binding<T?>? to Binding<T?> in SwiftUI?

I have an init like so: @Binding var height: Double? init(height: Binding<Double?>? = nil) { self._height = height } I am getting an error: Value of

Horizontal Calender with SwiftUI

I'm exploring my way through swift & swiftui trying to teach myself. My current challenge is to produce a horizontal calendar that scrolls on a single line

Make TextField autosearch when map is opening

I have a TextField at the top of my map in Xcode. The map is opening when you choose food, to find the nearest restaurant. I want TextField to search for the St

How do I detect when User has reached the bottom of the ScrollView?

I used the following code as a reference: SwiftUI - Get size of child? SwiftUI - How to get size (height) of ScrollView content Get the current scroll position

SwiftUI: preview doesn't display content in list [duplicate]

I have created a very simple test in SwiftUI: Pokemon struct Pokemon: Identifiable { let id: Int let name: String } PokemonList struc

Thread 4: Fatal error: 'try!' expression unexpectedly raised an error

I'm trying to learn to make an API call in swiftUI, I'm following the next tutorial https://www.youtube.com/watch?v=1en4JyW3XSI but the code is giving me an err

SwiftUI & WidgetKit: Why Intent Handler does not load saved data?

I'm building a Widget with dynamic configuration. I provide a dynamic list of options with an Intents Extension - inside Intent Handler (code below). However on

Restoring macOS window size after close using SwiftUI WindowsGroup

By default, on a macOS app using SwiftUI the window size is not restored after the window is closed. Is there a way to keep whatever size & position the use

How to execute a CPU-bound task in background using Swift Concurrency without blocking UI updates?

I have an ObservableObject which can do a CPU-bound heavy work: import Foundation import SwiftUI @MainActor final class Controller: ObservableObject { @Pub

Creating a macos windowless menu bar application with SwiftUI

I am looking for a solution to create a macos windowless menu bar application with SwiftUI. I have implement the function ralated to the menu bar, the problem i

How to enter the amount of shapes in for each identifiable loop SwiftUI

I am beginner in SwiftUI, updating my app and remaking it on SWIFTUI. Here is the screenshot what I had to do... Screenshot I've successfully done actually the

SwiftUI and tvOS: adjustsImageWhenAncestorFocused

How do you get the same focus effect in SwiftUI for images as you can with UIKit? I see you can use the card button style and it does provide motion effects but