Share Sheet Crashing on iPad
I implemented share sheets today as well and had the exact same issue. You need to add this before presenting.
if let popoverPresentationController = activityController.popoverPresentationController {
popoverPresentationController.sourceView = self.view
popoverPresentationController.sourceRect = CGRect(x: CGRectGetMidX(view.bounds), y: CGRectGetMidY(view.bounds), width: 0, height: 0)
popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0) //Removes arrow as I dont want it
}
Line 1 sets the source view.
Line 2 I use to Center the popover right in the middle (I use it in SpriteKit and the popover is not attached to anything)
Line 3 I use to remove the arrow as I don't want it.
Hope this helps
Present ActionSheet in SwiftUI on iPad
Finally, as tested in iOS 13.4 this has been resolved, at least in the beta. The conflicting constraints warning persists, but the crash is gone. This is now the appropriate way to present an action sheet.
import SwiftUI
struct ContentView : View {
@State var showSheet = false
var body: some View {
VStack {
Button(action: {
self.showSheet.toggle()
}) {
Text("Show")
}
.actionSheet(isPresented: $showSheet, content: { ActionSheet(title: Text("Hello"))
})
}
}
}
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
Related Topics
Xcode11 Error "Open(_:Options:Completionhandler:) Is Unavailable in Application Extensions"
Swift: +[Catransaction Synchronize] Called Within Transaction While Decoding HTML Entities
How Convert a *Positive* Number into an Array of Digits in Swift
Swift 3 - Pass Struct by Reference via Unsafemutablerawpointer
Making Sklabelnode as a Crop Node of Skshapenode
How to Load Nsview from Xib with Swift 3
Get Current Url from Browser in MACos
Why Are Objects in the Same Sknode Layer Not Interacting with Each Other
Swift Protocol as Generic Parameter
Swiftui View Does Not Updated When Observedobject Changed
Avaudiosinknode with Non-Default, But Still Device-Native Sample Rates
Why Does This Swiftui Picker Code Not Work
How to Pass Image Value to The Imageslideshow Using Swift
Can't Create Default Closure Parameter in Array Extension Method in Swift
How to Compare Cgpoints in Swift
Numeric Types Don't Automatically Bridge to Nsnumber in Pure Swift on Ubuntu Linux