Questions tagged [swiftui-environment]

141 questions
0
votes
1 answer

Using @Environment PresentationMode in SwiftUI View and UIViewControllerRepresentable Causing Problems

I am working on a SwiftUI project that is using a UIImagePickerController through UIViewControllerRepresentable. In the UIViewControllerRepresentable file I add the following line so that I can dismiss the ImagePicker in imagePickerController…
jonthornham
  • 2,881
  • 4
  • 19
  • 35
0
votes
1 answer

SwiftUi Extra Argument in Call When calling two views of @EnvironmentObject in main view

When calling one view environment object in main view thats ok build successful but when I call second view environment object its throw an error extra argument in call. struct mainView: View{ @EnvironmentObject var userInterestVM:…
0
votes
1 answer

How to use function from other struct/view in SwiftUI?

Newbie SwiftUI Dev here. I want to create a scheduling app in SwiftUI and I would like to create a button in navigation bar which change calendar's scope. From .week to month and return. struct HomeVC: View { init() { …
0
votes
1 answer

SwiftUI: How to pass an argument from one view to the next with dynamically generated buttons?

Problem: I am unable to force my alpha, beta, or gamma buttons to turn ON when an input parameter is passed from Landing.swift. I do not understand why when onAppear fires in the stack, the output becomes: gamma is the title beta is the…
ninu
  • 890
  • 2
  • 10
  • 26
0
votes
0 answers

Declare array property with @published var inside same ObservableObject

I'm trying to declare Array with a @Published var property. However, the value is never updated (Always the default -> 0). How can I do that ? What am I doing wrong ? Thank you very much for your help ;) Have a nice day struct MyCategory:…
Chéramy Alexandre
  • 444
  • 3
  • 8
  • 25
0
votes
1 answer

SwiftUI: Animation covers text while in Zstack

my app is having appearance dark , i don't know if its really matters or not but i am doing an animation on my app ( Complex UI - custom slide out menu ) then after i did everything good and layout for my dark appearance seems fine , every time i…
0
votes
1 answer

Passing data across views for unique objects in a forEach loop in swift

I have two views, ViewAssignment and TaskDetailView. My ViewAssignment page fetches data from an environment object, and creates a list using the data. Upon each item of the list being clicked on, the TaskDetailView pops in as a navigation link,…
0
votes
1 answer

How do I navigate to another SwiftUI View when an Environment Object update is causing the same view to reload

What I'm trying to achieve: I'm a new SwiftUI developer. I'm trying to build a simple Address Book app. I have three views: ContentView - The main view which contains all contacts in a List View with an Add Contact ('+') and Edit button at the top…
0
votes
1 answer

Cannot convert value of type 'String' to specified type 'NWEndpoint.Host'

SwiftUI code to send commands trough UDP What I want I need to set this: var hostUDP: NWEndpoint.Host = "192.168.0.205" //Line I want to fill with dispositive.ip var portUDP: NWEndpoint.Port = 3489 //Line I want to fill with dispositive.port to…
0
votes
0 answers

SwiftUI No ObservableObject of type ObservableTest found. A View.environmentObject(_:) for ObservableTest may be missing as an ancestor of this view

To reproduce the problem, please use the following code and do the following Operation steps: click TestB View twice, scroll down to close the page, and the above problem will occur in the process. import SwiftUI @main struct SwiftUIStudyApp: App…
0
votes
0 answers

Crash on implementing DFS in SwiftUI

I am a newbie to SwiftUI and I was trying to make a DFS (Depth First search) visualizer in SwiftUI. I have the following code. // // Maze.swift // BookCore // // Created by Subhronil Saha on 14/04/21. // import Foundation class Maze:…
0
votes
1 answer

Picker selection from property of EnviromentObject

I've a problem with Picker selection when I use my EnviromentObject. My enviroment Object is UserSettings where users save them preferences, like language, currency and so on. I added this object in the the contentview, as enviroment object,…
0
votes
0 answers

SwiftUI having @Environment(\.presentationMode) for dismissing view misbehaving

I have a view with @Environment(\.presentationMode) var presentationMode: Binding for a custom dismiss action based on a published value around some logic like this: .onAppear(perform: { viewModel.cancellable =…
Hesham
  • 132
  • 2
  • 12
0
votes
1 answer

How to show alert message in swiftUI when user enters time below the expected time?

I'm building an alarm kinda app and I just want to display a pop up message (alert message) when user enter time below 2 hours, the user should get a message by saying like, "please enter time more than 2 hours of duration". This is where I stored…
0
votes
1 answer

How to switch between views using @State and fullScreenCover in SwiftUI

I'm trying to figure out how to switch between views using @State and fullScreenCover in SwiftUI I have a main view and 2 simple views (View1 and View2). View1 must open on the tap of the "Show view 1" button, and View2 when typing on the "Show view…
Adelmaer
  • 2,209
  • 3
  • 22
  • 45