![](/img/trans.png)
[英]Failed to get remote view controller with error: Error: domain=_UIViewServiceInterfaceErrorDomain, code=2
[英]_UIViewServiceInterfaceErrorDomain
我遇到了MFMailComposeViewController
的問題
我收到了這個錯誤
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=... {Message=Service Connection Interrupted}
用這個代碼
- (IBAction) mailbutton:(id)sender
{
if([MFMailComposeViewController canSendMail])
{
[MSAPP.globalMailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:MSAPP.globalMailComposer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to mail. No email on this device?"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[MSAPP cycleTheGlobalMailComposer];
}
}
這是iOS 8模擬器的已知問題。 請參閱此帖子以獲取可能的解決方法。
您必須在早期階段分配和啟動MFMailComposeViewController,並在需要時將其保存在一個靜態變量中,獲取靜態MFMailComposeViewController實例並顯示它。
並且你幾乎肯定必須在每次使用后“循環”全局MFMailComposeViewController。 “重復使用”同一個是不可靠的。 有一個全局例程,它釋放然后重新初始化單例MFMailComposeViewController。 完成后每次調用它
這篇文章歸功於“Joe Blow” 。 根據您的代碼判斷,您已經聲明了全局郵件編寫器。 嘗試“回收”它,如帖子建議,看看是否能解決您的問題。 我有同樣的問題,不幸的是這個解決方案並沒有解決我的問題。 我可以確認這個解決方案適用於iOS 7.1模擬器但不適用於iOS 8,盡管有人建議它可以在物理iOS 8設備上運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.