如何在Xamarin.iOS应用程序中使用c#在Instagram上发布类似于SLComposeViewController的图片。
发布于 2016-04-14 21:58:21
我不认为你可以像SLComposeViewController那样和Instagram或Facebook分享额外的文本。看一看here
最好使用UIActivityViewController,并将图像添加到activityItems,如答案https://stackoverflow.com/a/32783758/1107580中所示
发布于 2017-05-24 07:18:13
目前有两种方法可以将你的应用程序中的图片分享到Instagram上:
下面是第二个选项的Xamarin代码:
UIImage imageToUse = _your_ui_image_instance;
NSString documentDirectory = (new NSString(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
string saveImagePath = documentDirectory.AppendPathComponent(new NSString(@"Image.ig"));
NSData imageData = imageToUse.AsPNG();
imageData.Save(saveImagePath, true);
NSUrl imageURL = NSUrl.FromFilename(saveImagePath);
DocumentController = new UIDocumentInteractionController();
DocumentController.Url = imageURL;
DocumentController.Uti = "com.instagram.photo";
DocumentController.PresentOpenInMenu(new RectangleF(1, 1, 1, 1), View, true);记住要将DocumentController声明为类的字段,而不是本地属性(一旦PresentOpenInMenu过早丢失UIDocumentInteractionController,就会出现错误)。
您也可以使用uti com.instagram.exclusivegram和extension .igo在操作表中显示更少的应用程序。
https://stackoverflow.com/questions/36623434
复制相似问题