我想通过我的应用程序在Instagram应用程序中共享图像。如何通过一个应用程序在Instagram中共享图像
请检查我的代码下面,请让我知道我错了什么地方。
_instagramURL = [NSURL URLWithString:[NSString stringWithFormat: @"instagram://media?id=%@",[SingletoneClass sharedSingleTone].imageId]];
if ([[UIApplication sharedApplication] canOpenURL:_instagramURL]) {
self.dic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[SingletoneClass sharedSingleTone].imagePath]];
self.dic.delegate = self;
self.dic.UTI = @"com.instagram.exclusivegram";
self.dic.annotation = [NSDictionary dictionaryWithObject:[SingletoneClass sharedSingleTone].captionStr forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect: CGRectZero inView:self.view animated:YES ];
}
else {
UIAlertController *alert = [[SingletoneClass sharedSingleTone] setAlertControllerWithTitle:@"" message:@"Instagram is not present in your device" andCallback:^(id actionResponse) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[self presentViewController:alert animated:YES completion:nil];
}
如果上面的代码是正确的,那么请让我知道,从哪里可以找到imageId?
您可以添加关于SingletonClass文件的描述。它返回什么对象。你可能会问: –
@AnilGupta询问, UIAlertController * alert = [[SingletoneClass sharedSingleTone] setAlertControllerWithTitle:@“”message:@“Instagram is not in your device”andCallback:^(id actionResponse){alertdismissViewControllerAnimated:YES completion :零]; }]; –
如果您要从Photo Gallary或Images资源共享图像,而不是简单地将图像对象路径传递到“_instagramURL”中。您可以通过注册您的applcation从https://www.instagram.com/developer/找到imges ID。但分享你不需要注册你的应用程序。 –