Post

Replies

Boosts

Views

Activity

Type 'DefaultNavigationViewStyle' has no member 'automatic'
I am trying to show a StackNavigationView for my app's menu if the user is on iPad and the default Navigation view elsewhere. The reason is because on iPad the default view only shows the back button and nothing else, and the user has to click the back button to access the menu in portrait mode, which is not user friendly at all. Here is a simplified version of my code     @State var selectedView:Int?;     @Environment(\.colorScheme) var colorScheme;     var body: some View {         ZStack{         NavigationView{                 List{                     NavigationLink(destination: textChangeView(){                         Text("mOcK tExT")                     }                 NavigationLink(destination: textChangeView()) {                         Text("S P A C E D")                     }                 NavigationLink(destination: textChangeView() {                         Text("Windy text")                     }                     }                 }.navigationTitle("Options") // PROBLEM IS HERE         }.navigationViewStyle(UIDevice.current.model == "iPad" ? StackNavigationViewStyle() : DefaultNavigationViewStyle.automatic)         }         } The official SwiftUI documentation tells us to use automatic which is an attribute of DefaultNavigationStyle. Yet, I get the error Type 'DefaultNavigationViewStyle' has no member 'automatic' How can I set up my navigationViewStyle to be StackNavigationStyle and the default elsewhere ?
1
0
637
Jun ’21
Once you save a file using UIActivityViewController, the share button doesn't work anymore
When I implement UIActivityViewController on SwiftUI with an app that looks like this import SwiftUI struct ContentView: View {     @State private var isSheetPresented:Bool = false     var body: some View {         Text("Hello, world!")             .padding()         Button(action: {             self.isSheetPresented = true         }) {             Text("Share")         }.sheet(isPresented: $isSheetPresented) {             ActivityView(activityItems: ["this is some text that could normally be saved to files, but somehow, once you save it to files, or do something in other specific apps, the share button somehow doesn't work"], applicationActivities: [])             }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct ActivityView: UIViewControllerRepresentable {    var activityItems: [Any]     var     applicationActivities: [UIActivity]?    func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {       UIActivityViewController(activityItems: activityItems,                             applicationActivities: applicationActivities)    }    func updateUIViewController(_ uiViewController: UIActivityViewController,                                context: UIViewControllerRepresentableContext<ActivityView>) {}    } the share button works but once I save to the text to a file, and go back to my app, the share button doesn't work anymore, I click on it and the share button does nothing, Somehow this doesn't do the same thing with copying the text. I really wonder how to fix this.
1
0
1.6k
Dec ’20
Make a button click update the state var in a text field
My question seems very simple yet I can not find a solution yet. This is a minimal example of my problem, //  ContentView.swift //  update // //  Created by Louis Couture on 2020-12-10. // import SwiftUI struct ContentView: View {     @State var number = 0;     var body: some View {         Text(String(number));         TextField("enter number", value: $number, formatter: NumberFormatter())         Button(action: {print("what do do here")}, label: {             Text("save");         })              } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } How do I make it so whenever I click the save button, the value in the text field gets passed to state var number and displaying it without the user having to press enter ?
1
0
2.0k
Dec ’20
clicking on a navigation button works in iOS, but not in macOS or iPadOs
I have an app which sets different kind of scheduled timers, and while on iOS it works like a charm, there are issues with macOS and iPadOS. When I click on one button it and then the other, the switching works once, but on the other way around in does not. Shouldn't my current view be dismissed when I click on another Link, just like the view is being dismissed when I click on the back button on an iPhone? Here is my contentView file ContentView.swift - https://developer.apple.com/forums/content/attachment/4e34203a-8eff-430f-8c27-f78517287a30
2
0
500
Aug ’20