bevy / photo-editor

Photo editor with a lot of cool features
MIT License
882 stars 336 forks source link

Crop function: crash on iPad when opening the "constrain" alert sheet #37

Open thdankert opened 6 years ago

thdankert commented 6 years ago

Using the photo editor on the iPad, it will crash when trying to open the "constrain" alert sheet (in crop mode), because it does not have a barButtonItem or sourceRect/sourceView set.

Name: NSGenericException, Reason: Your application has presented a UIAlertController (<UIAlertController: 0x103ca6400>) of style UIAlertControllerStyleActionSheet. 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.

Can be fixed by setting the appropriate barButtonItem in CropViewController.swift, before present is called (around line 239):

actionSheet.popoverPresentationController?.barButtonItem = sender