애플의 리뷰어들은 보통 아이패드로 심사를 하는데 아이폰에서는 에러가 안나는 코드가 아이패드에서는 에러가 나는 경우가 있다.
UIAlertController를 사용할 때, 아래와 같이 빨간색 부분을 추가해줘야 한다.
let alert = UIAlertController(title: nil, message: "Delete?".localized(), preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Yes".localized(), style: .default , handler:{ (UIAlertAction)in
print("User click Approve button")
db.collection("notina").document(docId).delete() { err in
if let err = err {
print("Error removing document: \(err)")
} else {
print("Document successfully removed!")
self.navigationController?.popViewController(animated: true);
}
}
}))
alert.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel, handler:{ (UIAlertAction)in
alert.dismiss(animated: true, completion: nil)
}))
// 아이패드 용
if let popoverController = alert.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
}
self.present(alert, animated: true, completion: {
print("completion block")
})