Category "swiftui"

Fetching data in Preview: "A fetch request must have an entity UncaughtExceptionError"

I have a ListView file which can build the preview code fine without the Core Data piece in it. However, when I build that ListView in the ContentView, I got a

SwiftUI - How to center a component in a horizontal ScrollView when tapped?

I have a horizontal ScrollView, and within it an HStack. It contains multiple Subviews, rendered by a ForEach. I want to make it so that when these Subviews are

SwiftUI toolbar text size changes on appear

Related to this I am trying to make an app based on Notes app. I set my iPhone text size to the smallest, and when the view changes, the texts on new view's to

Changing the toolbar item placement on iPad

Let's take the Shortcuts app for example. On the iOS App: On the iPadOS App: As you can see, the toolbar items were on .navigationBarTrailing on iPhone, but i

SwiftUI, AppStorage and using Picker in TabViews

I am trying to save a small amount of data with picker using AppStorage across multiple views. However the issue I'm running into is that when I select one valu

SwiftUI : How I can delete the UIimage in the View saved as Codable?

I tried to save the image in my memo with as UIImage as Codable protocol. My code can be a little bit longer, but please refer to it. 1. first one is the NewMem

View is not updated when the data is changed with ForEach

I want to change rate parameter and display in ForEach. // ViewModel.swift @MainActor final class ViewModel: ObservableObject { let serviceContainer: Servi

Why does SwiftUI View background extend into safe area?

Here's a view that navigates to a 2nd view: struct ContentView: View { var body: some View { NavigationView { NavigationLink {

My view doesn't update after modifying an object of a list inside an ObservableObject

I am new to SwiftUI. Imagine I am building an app for a shop. I have a view that is a list of the details of a product, and two buttons: Pin (add to favorites)

How to save a UUID in SwiftUI using @AppStorage

When using @AppStorage("navigationWaypointID") var navigationWaypointID: UUID? I get a No exact matches in call to initializer. I can work around by using a St

NavigationLink is grayed out and does not perform any action [duplicate]

import SwiftUI struct ContentView: View { var body: some View { NavigationLink(destination: DetailView()) { Text(

SwiftUI animation not continuous after view change

Here is the testing code: import SwiftUI struct ContentView: View { @State private var pad: Bool = false @State private var showDot: Bool = true var body:

Failed to log metrics

There is no Buildtime or runtime error on my code. however, when I run the code it says succeeded and a black screen comes up. I get the following on my console

Why is are the images being cut off?

The images in my 'tiles' are being cut off at the sides. I am trying to create a tile for each 'product' that displays an image, name and subtitle. Everything n

RoundedRectangle background colour does not crop and TextEditor transparent background

I have a messaging interface. When user types in to the texteditor it will be append to messagesDBArray and will be displayed in textview. Once new messages are

SwiftUI - Custom map pin's onTapGesture action is selecting a wrong pin view when there are group of pins in the save position(Zindex bug)

My map code is actually really simple: // // ContentView.swift // MapTest // // Created by Asi Givati on 24/04/2022. // import SwiftUI import MapKit import

I can't draw responsive custom button with Path in SwiftUI ( I used Paint Code)

I was using PaintCode app for line to code. But I can't use this code.. Because this code is not responsive.. I don't want button sizes to be static. I don't wa

SwiftUI Preview incorrectly tries to build conditional dependency from another platform

SwiftUI Previews are broken for me when one of imported Swift Package has a conditional dependency to another platform. Steps to reproduce: Create Xcode Project

SwiftUI App crashes after second continuous open

I have a working SwiftUI app with a start animation that appears to sometimes cause it to crash - this happens only when the user quits the app completely right

How to use Button SwiftUI correctly?

There is a code that, by pressing the "Sign Up" button at the bottom of the screen, should open another window. But for some reason, when you click on the butto