2012-05-05 15 views
6

Ciao ho bisogno di importare il mio immagine modificata in Instagram, qualcosa come PhotoStudio:Aprire l'immagine con Instagram

enter image description here

ho catturato la mia immagine con questo codice:

UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0); 
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext(); 

    UIGraphicsEndImageContext(); 

poi ho bisogno di aprire questo screenShot con Instagram:


A cura:

a implementare il metodo come questo:

UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0); 
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]]; 

    docFile.UTI = @"com.instagram.photo"; 
    [self setupDocumentControllerWithURL:igImageHookFile]; 

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"]; 
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { 
     [[UIApplication sharedApplication] openURL:instagramURL]; 
    } 

    else { 
     NSLog(@"No Instagram Found"); 
    } 
} 

Ma ricevo questo output:

2012-05-05 21:55:36.842 InstantFrame[855:707] *** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit/UIKit-1914.84/UIDocumentInteractionController.m:1094 
2012-05-05 21:55:36.848 InstantFrame[855:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIDocumentInteractionController: invalid scheme (null). Only the file scheme is supported.' 

Instagram sarà aperto, ma non importa nulla.

+1

Vedere questa domanda: http://stackoverflow.com/questions/8302593/iphone-open-in-sdk – Jonathan

+0

hai fatto l'instagram? plz condividi con me instagram parte – Hiren

+0

Prova anche questa risposta: http://stackoverflow.com/a/5631674/2284713 Utilizzando [NSURL fileURLWithPath: urPath] per igImageHookFile ha funzionato per me. – weienw

risposta

1

Quello che vuoi fare è aprire un URL appositamente formattato.

Ecco la documentazione Instragram ho trovato con una breve ricerca su Google:

http://instagr.am/developer/iphone-hooks/

Ecco la documentazione di Apple che descrive il sistema di processo url. http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007891-SW1

+0

potresti vedere la mia domanda modificata? grazie –

+0

Il problema è come si imposta l'ID del documento. Stai impostando l'ID su "screenshot". Ma lo screen shot è un UIImage. Scopri come ottenere un ID immagine e usalo. – scord

0

Per condividere l'immagine su Instagram, la dimensione minima dell'immagine deve essere 612x612. Altrimenti, non importa l'immagine.