Instagram открывает UTI напрямую

Я недавно наткнулся на следующую интересную особенность: Instagram iPhone Hooks

Мне было интересно, можно ли сразу открыть приложение через documentinteractioncontroller, БЕЗ необходимости показывать предварительный просмотр ( - presentPreviewAnimated :) или лист действий (- presentOpenInMenuFromRect: inView: animated :). Мне кажется, что это единственный способ, но я могу что-то упустить.

-(void) saveToInstagram {
    NSURL *url;
    UIDocumentInteractionController *dic;
    CGRect rect = CGRectMake(0 ,0 , 0, 0);
    UIImage *i = imageView.image;
    CGRect cropRect = CGRectMake(i.size.width - 306 ,i.size.height - 306 , 612, 612);
    NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.ig"];
    CGImageRef imageRef = CGImageCreateWithImageInRect([imageView.image CGImage], cropRect);
    UIImage *img = [[UIImage alloc] initWithCGImage:imageRef];
    CGImageRelease(imageRef);

    [UIImageJPEGRepresentation(img, 1.0) writeToFile:jpgPath atomically:YES];
    url = [[NSURL alloc] initFileURLWithPath:jpgPath];
    dic = [self setupControllerWithURL:url usingDelegate:self];
    [dic presentOpenInMenuFromRect:rect inView:self.view animated:YES];
    [dic retain];
    [img release];
    [url release];
}

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id ) interactionDelegate {

    UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
    interactionController.delegate = interactionDelegate;

    return interactionController;
}

- (void)documentInteractionControllerWillPresentOpenInMenu:(UIDocumentInteractionController *)controller {

}

14
задан ThomasM 29 June 2011 в 15:48
поделиться