UidocumentInteractionController Annotation Property non copia la didascalia per presentare domanda
-
21-12-2019 - |
Domanda
Grazie a un paio di altri messaggi qui, ho successo con successo i ganci IPSAGRAM per iPhone per aprire Instagram e presentarlo con una foto correttamente dalla mia applicazione.
(Ho reso la mia classe ViewController
Classe A delegate
di UIDocumentInteractionController
e alloc/init
'ed A nonatomic/retain property
di UIDocumentInteractionController
...
Tuttavia, la chiave che ho inserito nel mio NSDictionary
che metto nella proprietà di annotazione del controller del documento non sembrano trasportare su Instagram - l'area della didascalia è completamente vuota.
Come posso affrontare questo?
Ecco il mio metodo:
- (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.");
}
}
.
Ci sono alcuni metodi che vengono chiamati qui che non ho incluso, uno diplomato all'immagine per assicurarsi che il suo 612x612 e una configura l'URL del file per il controller del documento.
Soluzione
La corretta sintassi dovrebbe essere
self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:@"InstagramCaption"];
.