Post not yet marked as solved
Post marked as unsolved with 1 replies, 845 views
Hello there!
I'm stuck at integrating an EKCalendarChooser in my SwiftUI App.
Well, basically it works, but the Sheet shows no NavigationBar, NavigationBarButtons or ToolbarButtons.
Thats my code, it works perfectly fine with other UIKit integrations (e.g. EKEventEditViewController). But it seems to be different for EKCalendarChooser.
import SwiftUI
import EventKitUI
struct eventCalendarChooser: UIViewControllerRepresentable {
@EnvironmentObject var manager: EventsCalendarManager
		@Binding var selectedCalendars: [EKCalendar]
		init(selectedCalendars: Binding<[EKCalendar]>) {
self._selectedCalendars = selectedCalendars
}
typealias UIViewControllerType = EKCalendarChooser
func makeUIViewController(context: Context) -> EKCalendarChooser {
let vc = EKCalendarChooser(selectionStyle: .multiple, displayStyle: .allCalendars, entityType: .event, eventStore: eventStore)
vc.showsCancelButton = true
vc.showsDoneButton = true
vc.delegate = context.coordinator
return vc
}
func makeCoordinator() -> Coordinator {
return Coordinator(self)
}
func updateUIViewController(_ uiViewController: EKCalendarChooser, context: Context) { }
class Coordinator: NSObject, EKCalendarChooserDelegate, UINavigationControllerDelegate {
func calendarChooserDidFinish(_ calendarChooser: EKCalendarChooser) {
self.parent.selectedCalendars = Array(calendarChooser.selectedCalendars)
calendarChooser.dismiss(animated: true)
}
var parent: eventCalendarChooser
init(_ parent: eventCalendarChooser) {
self.parent = parent
}
}
}
Any help is appreciated, thank you very much in advance!