gpt4 book ai didi

c# - 呈现 ModalView 时出现 NSInvalidArgumentException

转载 作者:行者123 更新时间:2023-12-01 19:22:22 25 4
gpt4 key购买 nike

异常消息:

Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: 
Application tried to present a nil modal view controller on target <Navigator: 0x1bed0d0>.

这是我的代码:
    partial void BtnTest (MonoTouch.Foundation.NSObject sender)
{
MFMailComposeViewController view = new MFMailComposeViewController();
view.SetToRecipients(new string[]{"blubb@blubb.de"});
view.SetMessageBody("Hier steht nun der zusammengestellt text :)", false);
//view.MailComposeDelegate = new CustomMailComposeDelegate();
view.SetSubject("Test");

view.Finished += (s,e)=>
{
this.NavigationController.DismissModalViewControllerAnimated(true);
};

this.BeginInvokeOnMainThread(()=>
{
this.NavigationController.PresentModalViewController(view, true);
});

}

它适用于 iPad 模拟器,但不适用于设备。

最佳答案

将此声明移到您的方法之外。一旦超出范围,它很可能会立即获得 GC。

MFMailComposeViewController view;

关于c# - 呈现 ModalView 时出现 NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9701833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com