Exception Message:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason:
Application tried to present a nil modal view controller on target <Navigator: 0x1bed0d0>.
Here is my code:
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);
});
}
It works on iPad Emulator but not on the Device.
Is your device configured to send emails ? note that even if it is you should not consider it will be the case on every user devices.
IWO you should call
MFMailComposeViewController.CanSendMaillike this is documented by Apple. Two important quotes:and
Example: