Skip to content

Commit d320abf

Browse files
authored
Merge pull request #46 from Metaxa007/feature/alert-bug-on-ipad
Fix save-alert on iPad.
2 parents 518f9e5 + 4b39669 commit d320abf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

OpenDocumentReader/DocumentViewController.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,17 @@ class DocumentViewController: UIViewController, DocumentDelegate {
219219
}
220220

221221
func showToast(controller: UIViewController, message : String, seconds: Double, color: UIColor? = .gray, completion: (() -> Void)? = nil) {
222-
let alert = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
223-
// TODO: fix text invisible on iPad: https://github.com/TomTasche/OpenDocument.ios/issues/42
224-
//alert.view.backgroundColor = color
222+
let alert: UIAlertController!
223+
224+
if UIDevice.current.userInterfaceIdiom == .pad {
225+
alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
226+
} else {
227+
alert = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
228+
}
229+
230+
alert.view.backgroundColor = color
225231
alert.view.layer.cornerRadius = 15
226232

227-
alert.popoverPresentationController?.sourceView = menuButton.value(forKey: "view") as? UIView
228233
controller.present(alert, animated: true)
229234

230235
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + seconds) {

0 commit comments

Comments
 (0)