Questions tagged [swiftui-environment]
141 questions
0
votes
2 answers
Problem uploading an app to iTunes Connect
After experimenting a bit with SwiftUI making a new iOS app; I just got to the point where I want to put it on TestFlight to start testing with more people.
But this is where I am hitting a new problem.
After archiving, here is what I get when…

Michel
- 10,303
- 17
- 82
- 179
0
votes
2 answers
@Published doesn't work as expected with enviornment object and nested ObservableObejct
Say I have UserSettings EnviornmentObject and one of it's properties is a class, the problem is when I change a value of that class, the EnviornmentObject won't publish these changes. I understand why, but I can't seem to find a workaround.
Here is…

Muhand Jumah
- 1,726
- 1
- 11
- 26
0
votes
1 answer
Reload data in SwiftUI using MVVM using filters
I have this code in an MVVM code in SwiftUI. My Objective is when the app loads for the first time to return the result without the filter. When I press the button on the view to trigger CatLotViewModel to reload the filtered data but can't seem to…

G B
- 2,323
- 3
- 18
- 32
0
votes
1 answer
Safari view in swiftui displaying empty view
Hi everyone I am trying to display safari view as full screen modal using ZStack
ZStack
{
HStack
{
VStack
{
Safari(url: url)
}
}
…

Johanna
- 169
- 3
- 7
0
votes
1 answer
Padding List to avoid keyboard overlapping
Before you mark this like duplicate please read the following
I'm trying to make an iPhone and iPad app, and i have this common issue with the keyboard overlapping the text input. i tried all most every solution from this site but I didn't find one…

Misael Landeros
- 545
- 5
- 18
0
votes
1 answer
How to pass value from class to struct in SwiftUI
I got class:
class ImagePickerCoordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate, ObservableObject{
@Published var display = "Name"
@Binding var image: UIImage?
@Binding var isShown: Bool
…

newbieHere
- 276
- 2
- 15
0
votes
1 answer
Is there a way to Init CoreData AND EnvironmentObject in SceneDelegate?
how do I initialise both, the managedObjectContext and the .environmentObject in the scenedelegate root view ?
I tried all variations of this code - it didn't work:
let contentView = ContentView().environment(\.managedObjectContext, context)
…

robsldczk
- 11
- 3
0
votes
2 answers
Long RTL Text gets cut-off/overflown on right in SwiftUI
I have a bit long RTL (Hebrew) texts that I want to display in full (on multiple lines, without wrapping), and it keep gets overflown/cut-off on right, no matter how I tried to fix it.
This is actually a problem in the Text component but it worth…

dabombs
- 1
- 1
0
votes
1 answer
TextField accept limited characters SwiftUi
I am having one textfield and I am using it to enter email and when a user clicks the send button, the email is deleted from the same textfield and its placeholder changes to enter pin. So when the user enters pin, I would like to make the text…

user12723399
- 127
- 1
- 1
- 5
0
votes
2 answers
Update a row in a list (SwiftUI)
I'm an early bird in programming so I know this question can be ridiculous from the point of view of an expert but I'm stuck in this situation from several days.
I would like to update a row by using a button "Edit" (pencil) after having used…

Stefano Zambrini
- 13
- 1
- 5
0
votes
0 answers
How can I "forward" the entire SwiftUI environment to another view?
It seems that certain SwiftUI views create new environment contexts, such as NavigationLink. None of the environment is available in the new view.
As a workaround, I've been just manually forwarding through environment variables, like this:
struct…

Wil Gieseler
- 1,893
- 1
- 17
- 18
0
votes
0 answers
Any way to share global variables between Struct & Class? @Environment doesn't work
Scenario:
I have a tabbed-based application with parallel network routines of similar function.
Each has has its own network error handler which sends out a @Published alert flag to notify the calling host's alert operator to display the…

Frederick C. Lee
- 9,019
- 17
- 64
- 105
0
votes
1 answer
Can I use @EnvironmentObject in SwiftUI for all shared data?
There are @State, @ObservedObject and @EnvironmentObject bindings in SwfitUI to share data between views and other objects. Each has its designated usage but @EnvironmentObject seems to be the most powerful and easiest to use. So, can I use it for…

Efe U
- 3
- 4
0
votes
1 answer
SwiftUI "environment-dependent" Color
In Apple's documentation, Color is defined as: "An environment-dependent color." (emphasis mine)
https://developer.apple.com/documentation/swiftui/color
Is it correct, therefore, to say that a SwiftUI Color is not constant but that the color of the…

Vince O'Sullivan
- 2,611
- 32
- 45
-1
votes
1 answer
Thread 1: Fatal error: No ObservableObject of type __ found. A View.environmentObject(_:) for __ may be missing as an ancestor of this view
When ever I try to run my program, I get a fatal error that 'A View.environmentObject(_:) for __ may be missing as an ancestor of this view.', and I don't really understand the error.
Here's my code:
import SwiftUI
struct ContentView: View {
…