Questions tagged [swiftui-environment]

141 questions
1
vote
1 answer

How we can find out iPad orientation in SwiftUI, automatically getting notification or get update with a function?

I want to get notified when user changes iPad orientation. In UIKit that was easy but I do not know how we can get that information with SwiftUI?
ios coder
  • 1
  • 4
  • 31
  • 91
1
vote
1 answer

SwiftUI @EnvironmentObejct can't seem update values

I'm trying to use @EnvironmentObject to update the Boolean values in the ViewModel. So when I navigate back to the original screen I want the boolean values to have change and therefore changing the text. Tried this with ObservedObject too. This is…
1
vote
0 answers

Universal links in SwiftUI

Can someone please help me, Im new to swiftUI and I want to implement universal link for my app. I have prepared my AASA and also added associated domain to the app. But I am confused when it comes to the code in Scene delegate for opening the app…
1
vote
1 answer

Get View Size inside Grouped List in SwiftUI

I'm currently using a List with a GroupedListStyle(), and with a .regular horizontalSizeClass (e.g an iPad in landscape mode), this style of List automatically creates some padding to each section, like this: struct ListView: View { var body:…
riciloma
  • 1,456
  • 2
  • 16
  • 31
1
vote
0 answers

How to call multiple api with alamofire in ObservableObject: SwiftUI

I am trying to call the api in my SwiftUI project, For this I want to create the BaseService.swift file in this I will put the common functionality of Alamofire and after that I wish to create on ObservableObject class in this class I want to call…
Tak Rahul
  • 176
  • 7
1
vote
0 answers

Is it possible to change the tint color of an alert in SwiftUI?

Hey I would like to change the tint color of an alert in SwiftUI, i tried .accentColor(.red) but it is not working.
Johanna
  • 169
  • 3
  • 7
1
vote
0 answers

Want to convert this code into Pure SwiftUI code. no autolayout, no UIViewRepresentable, no UIHostingController

Code is working want to convert into Pure SwiftUI code. without UIViewRepresentable, UIHostingController please let me know how can I achieve. Thanks * struct PathAnimatingView: UIViewRepresentable where Content: View { var path: Path let content:…
1
vote
0 answers

In SwiftUI, can you pass down bindings to nested views, if the bindings are derived from an EnvironmentObject?

In the following working example, editing the name of the published Test.Data will work, editing the name of the parent will work, but editing the name of the child will cause the NavigationView to pop. Is there any way for the NavigationView to…
coenttb
  • 21
  • 2
1
vote
1 answer

How we get the data and show like viewdidload using swiftUI

i'm trying to work with swiftUI but i'm having an issue. i want to fetch the data from firebase and show that data to the list. i used mutating function to modify the variable. now when i called that function than it give me error. how i can solve…
Sourav Mishra
  • 501
  • 4
  • 21
1
vote
1 answer

What does Apple mean by @ObjectBinding should be passed over through view?

I've been newly studying SwiftUI. And since I've seen Data flow over SwiftUI video from Apple explaining difference between @ObjectBinding and @EnvironmentObject, a question has come to my mind. What does apple mean by : You have to pass around the…
Parsa Noori
  • 198
  • 1
  • 1
  • 10
1
vote
1 answer

SwiftUI set string value inside UserDefaults but as a `EnvironmentObject`

Hello exist a easy way to put values inside UserDefaults as EnvironmentObject to be displayed in other views? Something like set username in the SettingsView and be displayed in the DashboardView. Thx a lot
1
vote
1 answer

EnvironmentVariables not working when passing variable from one view to another in SwiftUI

I have found a few similar examples of how to pass variables among multiple views in SwiftUI: Hacking with Swift - How to use @EnvironmentObject to share data between views How to pass variable from one view to another in SwiftUI I am trying to…
Dan Segall
  • 11
  • 2
1
vote
0 answers

SwiftUI binding a variable of another object is not working

I want for my view model to have state to bind not in main view. In the code below, I Binded view model's @GestureState variable to DragGesture in my main view. But the problem is, without any compile error, it does not updating my @GestureState…
Jex Jang
  • 567
  • 1
  • 4
  • 9
1
vote
0 answers

"Use of unresolved identifier" in SwiftUI project

I am creating my 1st SwiftUI project. All was going well until I added a new class (an XML parser) to the project. Now I get the error "Use of unresolved identifier" when I try to invoke the new class. It seems like the compiler isn't aware of the…
Bassman
  • 353
  • 5
  • 17
0
votes
0 answers

Swiftui optional picker get deselected any time environment object changes

Hi everybody and thanks in advance for your help I have a problem with a picker selection the main idea is We mave a main view, which presents a list of List Pressing on item in list gives you another view of Meters, but at once, there are no meter,…
Roman R
  • 39
  • 8