UIAlertController actionSheet Exception 錯誤解法


Fatal Exception: NSGenericException
Your application has presented a UIAlertController (<UIAlertController: 0x101833000>) of style UIAlertControllerStyleActionSheet from MoonBlock.DPTabBarController (<MoonBlock.DPTabBarController: 0x101818200>). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.



let alert = UIAlertController(title: "", message: "", preferredStyle: .actionSheet)