我使用了以下代码,但它没有用。我想将我的应用程序中的图像放到我 iPhone 上安装的 Instagram 应用程序中。
NSString *fileToOpen = [[NSBundle mainBundle] pathForResource:@"IMG_0192" ofType:@"jpg"];
fileToOpen = [fileToOpen substringToIndex:[fileToOpen length] - 3];
fileToOpen=[NSString stringWithFormat:@"%@ig",fileToOpen];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
NSLog(@"%@",fileToOpen);
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
//imageToUpload is a file path with .ig file extension
/*UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@""
message:@"Can open app!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
*/
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToOpen]];
self.documentInteractionController.UTI = @"com.instagram.photo";
self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Its a testing" forKey:@"InstagramCaption"];
我尝试了很多,但它根本不起作用。