Posts

Post not yet marked as solved
4 Replies
6.6k Views
I'm on 10.14.5 Mojave and have non-beta Xcode 10.2.1 installed.After I downloaded the xip file from my dev account and unzipped it, I tried running the "Xcode-beta".All that happened was a dialog box popped up saying "Required content for platform iOS Simulator is missing. Please reinstall Xcode" I tried moving it to my Applications folder, but this didnt help either.Any suggestions?In my Xcode 10.2.1 I can run the simulator.Thank you!
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.9k Views
I have a MainView, which is my rootViewController, in SwiftUI.In there is a @State var myString : String that is bound to a Textfield.Theres a button that presents a UIViewController "MyViewController" from the rootViewController when pressed.The MyViewController has a delegate that calls a function delegateEnds in which I want to set the myString from the presentingViewController (line 11 of MyViewController.swift) to a certain value that a delegate (MyDelegate) delivers.This is where the error is happening: Thread 1: Fatal Error: Accessing State<String> outside View.bodyHow can I resolve this problem? My goal is to present the UiViewController and get a string result from it down to the MainView's myString variable that is bound to the Textfield, so that the TextField updates right away.Since I can't change the @state variabe from outside the view appearently, is there any other way?Thanks in advace! MainView.swift:struct MainView : View { @State var myString: String = "" var body: some View{ VStack{ TextField($myString) Button(action:{ let rootVC : UIViewController = UIApplication.shared.keyWindow!.rootViewController! rootVC.present(MyViewController.init(), animated: true, completion: nil) }) } } }MyViewController.swift:class MyViewController : UIViewController , MyDelegate { override func viewDidLoad(){ super.viewDidLOad() //...some delegatestuff } func delegateEnds(withResult result: String!){ if let presenter = presentingViewController { let pres= presenter as! UIHostingViewController pres.rootView.myString = result.resultString } self.dismiss(animated: true, coimpletion: nil) } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
I have a Modal view that seems to overlap the screen of my iPhoneX.This is DetailView.swift.import SwiftUI struct DetailView : View { @Binding var shouldDismiss : Bool var textData : String var image : UIImage? @Environment(\.isPresented) private var isPresented var body: some View { VStack( alignment: .leading) { Button(action: { self.shouldDismiss.toggle() }) { Text("Close") }.font(.title) .foregroundColor(Color.secondary) .padding() Image(uiImage: image ?? UIImage()) .padding() Text(textData) .lineLimit(0) Spacer() } } }This is where the view is being pushed:ZStack { ... }.presentation(showDetails ? Modal(DetailView(shouldDismiss: $showDetails, textData: theTxtData, image: theImage), onDismiss:{ self.showDetails = false }) : nil)The DetailView overlaps on both sides of the screen. The text on the close Button is cut off (The "C" is not visible). Same goes for the image and the textData filed.
Posted Last updated
.