Instagram Video iPhone Hook

后端 未结 2 529
迷失自我
迷失自我 2021-01-01 07:37

The current best solution:

https://stackoverflow.com/a/21888830/1786820

I am trying to do one better, by opening the Instagram app with a preselected video f

2条回答
  •  情书的邮戳
    2021-01-01 08:19

    The answer is that it is not pulling the video from the camera roll at all, it might just look like it is.

    Documentation here: http://instagram.com/developer/mobile-sharing/iphone-hooks/

    The relevant bit is the bottom section "Document Interaction".

    You would do this by doing something like this:

    NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"];
    NSData *data = // set this yourself
    
    NSError *error = nil;
    if (! [data writeToFile:filePath options:NSDataWritingAtomic error:&error])
    {
        // error here
    }
    
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
    self.documentInteractionController.delegate = self;
    self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
    self.documentInteractionController.annotation = @{ @"InstagramCaption" : @"caption text here" };
    const BOOL couldOpen = [self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:myView animated:YES];
    

    Set the data, the caption, and the view to present from yourself. Notice the UIDocumentInteractionController is also a property. It should be retained somewhere and not just a local variable in a method because it needs to exist outside of that scope when the method completes.

提交回复
热议问题