I am using Xcode 6 to develop an iOS Application.
When I used UIAlertController, it can be worked well on iPhone 6 simulator, but crashes on iPad simula
I use this handy extension to create action sheets that never crash
extension UIAlertController {
class func actionSheetWith(title: String?, message: String?, sourceView: UIView?, sourceFrame: CGRect?) -> UIAlertController {
let actionController = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
if actionController.responds(to: #selector(getter: popoverPresentationController)) {
actionController.popoverPresentationController?.sourceView = sourceView ?? StoryboardHelper.tabBarControllerTopController()?.view
actionController.popoverPresentationController?.sourceRect = sourceFrame ?? CGRect(x: 0, y: 0, width: 0, height: 0)
}
return actionController
}
}