Skip to content

Commit

Permalink
Added action sheet for ipad
Browse files Browse the repository at this point in the history
  • Loading branch information
anupamchugh committed Oct 22, 2019
1 parent 9a8c84b commit de3d5de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion iOSMapAndPencilKit/iOSMapAndPencilKit/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ViewController: UIViewController {
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil)
})
alert.addAction(UIAlertAction(title: "Cancel", style: .destructive, handler: nil))

addActionSheetForiPad(actionSheet: alert)
present(alert,
animated: true,
completion: nil)
Expand Down Expand Up @@ -154,3 +154,13 @@ extension UIAlertController {
setValue(vc, forKey: "contentViewController")
}
}

extension UIViewController {
public func addActionSheetForiPad(actionSheet: UIAlertController) {
if let popoverPresentationController = actionSheet.popoverPresentationController {
popoverPresentationController.sourceView = self.view
popoverPresentationController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popoverPresentationController.permittedArrowDirections = []
}
}
}

0 comments on commit de3d5de

Please sign in to comment.