Я пробовал несколько способов использовать UIAlertController, а не UIAlertView, но я не могу сделать предупреждение. Заранее благодарим за любые дальнейшие предложения. Я новичок.UIAlertView 'устарел в iOS 9.0
UIAlertView 'устарел в iOS 9.0: UIAlertView устарел. Используйте UIAlertController с preferredStyle из UIAlertControllerStyleAlert вместо
Вот мой код:
import MessageUI
class SecondViewController: UIViewController,MFMailComposeViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func sendmail(sender: UIButton) {
let mailComposeViewController = configuredMailComposeViewController()
if MFMailComposeViewController.canSendMail() {
self.presentViewController(mailComposeViewController, animated: true, completion: nil)
} else {
self.showSendMailErrorAlert()
}
}
func configuredMailComposeViewController() -> MFMailComposeViewController {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property
mailComposerVC.setToRecipients(["[email protected]"])
mailComposerVC.setSubject("App Feedback")
mailComposerVC.setMessageBody("Feature request or bug report?", isHTML: false)
return mailComposerVC
}
func showSendMailErrorAlert() {
let sendMailErrorAlert = UIAlertView(title: "Could Not Send Email", message: "Your device could not send e-mail. Please check e-mail configuration and try again.", delegate: self, cancelButtonTitle: "OK")
sendMailErrorAlert.show()
}
// MARK: MFMailComposeViewControllerDelegate Method
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
controller.dismissViewControllerAnimated(true, completion: nil)
}
}
Что не работает? Я вижу ваш код 'UIAlertView', но не вашу попытку' UIAlertController'. Существует множество учебных пособий. [Здесь] (http://nshipster.com/uialertcontroller/) является одним из них. –
Обновите свой вопрос, пытаясь использовать 'UIAlertController'. Объясните, что у вас есть. И выполните некоторые поиски. Существует множество примеров использования 'UIAlertController'. – rmaddy