我想通過我的應用程序在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。但分享你不需要註冊你的應用程序。 –