This happens when you try to present a action sheet in iPad. Luckily you can make your action sheet work across iPhone and iPad without writing different code for specific platform.Using popoverPresentationController?.sourceView
an example code is given below
let actionsheet = UIAlertController(title: "Action Sheet", message: "", preferredStyle: .actionSheet); let camera = CustomAction(title:"Camera", style: .default,handler: opencamera) let gallery = CustomAction(title: "Gallery", style: .default,handler:opengallery) let cancelAction = CustomAction(title: "Cancel", style: .cancel) actionsheet.addAction(camera) actionsheet.addAction(gallery) actionsheet.addAction(cancelAction) actionsheet.popoverPresentationController?.sourceView = <Your source view> //this will work on both iPhone and iPad in iPhone the action sheet will present normally but in iPad it will present from your source view. self.present(actionsheet, animated: true, completion: nil)
This will remove the crash and you will achieve desired behaviour in both iPhone and iPad