Die Annotationseigenschaft UIDocumentInteractionController kopiert keine Beschriftung in die dargestellte Anwendung

StackOverflow https://stackoverflow.com//questions/21013066

Frage

Dank einiger anderer Beiträge hier konnte ich die Instagram-iPhone-Hooks erfolgreich verwenden, um Instagram zu öffnen und ihm erfolgreich ein Foto aus meiner Anwendung zu präsentieren.

(Ich habe meine gemacht ViewController Klasse a delegate von UIDocumentInteractionController, Und alloc/init'ed a nonatomic/retain property von UIDocumentInteractionController...

Allerdings ist der Schlüssel, den ich in meinen gesteckt habe NSDictionary die ich in der Anmerkungseigenschaft des Dokumentcontrollers platziere wird nicht scheinen sich auf Instagram zu übertragen – der Untertitelbereich ist einfach leer.

Wie gehe ich damit um?

Hier ist meine Methode:

- (void) uploadImageToInstagram:(UIImage *)imageToUpload {
    NSLog(@"postToInstagramInBackground");

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {

        // Upscale to 612x612
        imageToUpload = [self upscaleImage:imageToUpload];

        // Get JPG + IGO Format
        NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/generate.igo"];
        [UIImageJPEGRepresentation(imageToUpload, 1.0) writeToFile:savePath atomically:YES];

        // Paths
        NSURL *imageURL = [NSURL fileURLWithPath:savePath];
        NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",savePath]];

        // Setup DocController
        self.docController.UTI = @"com.instagram.photo";
        self.docController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
        self.docController.annotation = [NSDictionary dictionaryWithObject:@"MyApp" forKey:self.caption.text];
        [self.docController setURL:imageURL];
        [self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES ];
    }
    else {
        NSLog(@"Instagram not installed in this device!\nTo share image please install Instagram.");
    }
}

Es gibt ein paar Methoden, die hier aufgerufen werden, die ich nicht aufgenommen habe, eine, die das Bild hochskaliert, um sicherzustellen, dass es 612 x 612 ist, und eine, die die Datei-URL für den Dokument-Controller einrichtet.

War es hilfreich?

Lösung

Die richtige Syntax sollte sein

self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:@"InstagramCaption"];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top