【发布时间】:2016-06-08 08:49:25
【问题描述】:
如何将我的应用中的音频文件共享给其他应用并从其他应用接收音频文件?
我无法附加音频文件。这是代码sn-p:
var fileData = NSUrl.FromFilename(path);
var item = UIActivity.FromObject(@"<html><body><b>URL</b>: <a href='" + url + "'>" + url + "</a></body></html>");// NSObject.FromObject(uiImage);
var activityItems = new[] { fileData };
NSString message = (NSString)"Test";
var activityController = new UIActivityViewController(activityItems, null);
activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null)
{
topController = topController.PresentedViewController;
}
topController.PresentViewController(activityController, true, () => { });
如果文件附加为邮件,我还想添加主题和正文。
试过了,但没有成功,出现错误。:
activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
activityController.SetValueForKey(NSObject.FromObject("The body value"), new NSString("body"));
我还想接收其他应用共享的音频文件。我已经使用依赖服务和意图过滤器在 android 中完成了该功能。对于 android,代码被添加到 mainactivity.cs 中,我使用意图过滤器来接受来自其他应用程序的音频文件。如何在 iOS 中做到这一点?
【问题讨论】:
-
你遇到了什么错误?
-
它不会在邮件中添加附件或正文。
标签: c# ios xamarin xamarin.ios