Post

Replies

Boosts

Views

Activity

Reply to clicking on a navigation button works in iOS, but not in macOS or iPadOs
StateObject is not available to me as I am not yet on MacOs Big Sur, and I really need to use the class But here is a woking example contents - https://developer.apple.com/forums/content/attachment/6b5d83bd-a837-4114-9efe-92a6c5386ad8 I also get this message, which may help to find the cause of the problem error - https://developer.apple.com/forums/content/attachment/808261d0-c0b2-4281-b7d1-b56d5b701b20
Aug ’20
Reply to Once you save a file using UIActivityViewController, the share button doesn't work anymore
I finally ended up finding a solution on my own. You need to set isSheetPresented back to false once you're done with it, else, it doesn't work, maybe because isPresented looks for change since the last call. Once you change it back to false through the completionHandler, the problem is fixed. 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(isSheetPresented:$isSheetPresented,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 {     @Binding var isSheetPresented:Bool    var activityItems: [Any]     var     applicationActivities: [UIActivity]?    func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {       let ac = UIActivityViewController(activityItems: activityItems,                             applicationActivities: applicationActivities)     ac.completionWithItemsHandler = {(activityType: UIActivity.ActivityType?, completed:                                         Bool, arrayReturnedItems: [Any]?, error: Error?) in         isSheetPresented = false;}     return ac;    }    func updateUIViewController(_ uiViewController: UIActivityViewController,                                context: UIViewControllerRepresentableContext<ActivityView>) {}    }
Dec ’20