タップするとUIAlertViewを表示するアプリケーションにUIButtonがあります。アラートビューには、iOSのメール作成画面を開くボタンがあります。タイプ 'UIAlertControllerStyle.Type'の値を期待される引数タイプ 'UIAlertControllerStyle'に変換できません
メールの作成画面がうまく機能していますが、ユーザーがメールを送信したり「キャンセル」したりすると、メールの作成画面は消えません。私が使用しているコードは、私はこのエラーを取得していますように動作するようには思えない。
は予想引数の型に型「UIAlertControllerStyle.Type」の値を変換できません「UIAlertControllerStyle」
var alert = UIAlertController(title: "Alert", message: "Your Device cannot send emails", preferredStyle: UIAlertControllerStyle)
である場合がありますどのようなここにいる?ありがとう!
var myMail: MFMailComposeViewController!
@IBAction func helpfeedbackAlert(_ sender: Any) {
if(MFMailComposeViewController.canSendMail()){
myMail = MFMailComposeViewController()
myMail.setSubject("Test")
myMail.setToRecipients(["[email protected]"])
self.present(myMail, animated: true, completion: nil)
}
else{
var alert = UIAlertController(title: "Alert", message: "Your Device cannot send emails", preferredStyle: UIAlertControllerStyle)
self.present(alert, animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func mailComposeController(controller: MFMailComposeViewController!, didFinishWith: MFMailComposeResult, error: NSError!){
switch result.rawValue {
case MFMailComposeResult.cancelled.rawValue:
print("Mail cancelled")
case MFMailComposeResult.sent.rawValue:
print("Your email has been sent!")
case MFMailComposeResult.failed.rawValue:
print("Email has failed to send: %@", [error!.localizedDescription])
default:
break
}
// Dismiss the mail compose view controller
controller.dismiss(animated: true, completion: nil)
}
1つの問題とだけ関連するコードにあなたの質問を絞り込むください。あなたは2つの全く異なる問題と無関係なコードをあまりにも多く持っています。 – rmaddy
@rmaddy確かに、私は投稿を編集しました。 – Miles