[英]Xamarin.ios: MFMailComposeViewController somewhat crashes when dismissed
我發現自己遇到了一個非常奇怪的問題。 在我們正在開發的應用程序中,有一個功能可以從應用程序本身發送郵件。
根據Xamarin的配方,MFMailComposeViewController是Xamarin.ios的使用方式。
https://developer.xamarin.com/recipes/ios/shared_resources/email/send_an_email/
似乎僅某些設備存在問題,但是我不清楚這種模式。
按下按鈕“發送”或“取消”時,將調用完成的委托。 這部分通常應關閉MailViewController。
在某些設備上,行為符合預期,從屏幕上刪除了Mail控制器,並顯示了底層控制器。 但是,在某些設備上,郵件控制器位於頂部,並且該應用程序不再響應。 調試器不顯示任何內容。
到目前為止,有人遇到過這個問題嗎? 可以通過某種方式解決嗎? 我正在閱讀obj-c或swift代碼中的一些類似行為,但是他們的解決方案沒有幫助我。
Swift中的MFMailComposeViewController不會關閉
這是我的代碼:
private void OnSendMailClick(object sender, EventArgs e)
{
if (MFMailComposeViewController.CanSendMail)
{
string receiptText = trx.isReversed ?
Utilities.GetTransactionAndRefundReceipt(trx, manager) : Utilities.GetReceipt(trx, true);
var mailController = new MFMailComposeViewController();
mailController.SetSubject(String.Format("Receipt number: {0}", trx.STAN));
mailController.SetMessageBody(receiptText, true);
mailController.Finished += OnSendResult;
PresentViewController(mailController, true, null);
}
}
完成的委托看起來像這樣:
private void OnSendResult(object sender, MFComposeResultEventArgs e) => e.Controller.DismissViewController(true, null);
事實證明,問題出在由UINavigationViewController繼承的MFMalComposeViewController的繼承中。 由於我已經在使用基礎UINavigationcontroller,所以有時會引起問題。 找到合適的解決方案后,我會在此處發布它作為答案。
問題解決了。 事實證明,問題出在我使用的nuget包中。
https://github.com/jdehlin/Xamarin-Sidebar/
從1.9.4版開始,此行為很容易在iPhone設備上重現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.