I am developing an application as a project for training. This is a meme sharing application. I use .sheet in order to present a modal view to share meme given as an image :
.sheet(isPresented: $showingSharePage) {
ShareSheet(items: items)
}
Here is my code for the share sheet :
struct ShareSheet: UIViewControllerRepresentable {
var items: [Any]
func makeUIViewController(context: Context) -> UIActivityViewController {
let controller = UIActivityViewController(activityItems: items, applicationActivities: nil)
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
}
}
Here is my share button's code :
ToolbarItemGroup {
AnimatedActionButton(title: "Share", systemImage: "square.and.arrow.up") {
items.removeAll()
let snapshot = meme.snapshot()
items.append(snapshot)
showingSharePage = true
}
}
The problem is that when I open for the first time (when application is launched), it doesn't show anything :
After after launching once, it works alright.
Why is it doing this ?
P.S : For further information, I share the whole GitHub project (this is a project for a course from Udacity) : https://github.com/m4thus4n/Project