UIDocumentInteractionController поделиться через Instagram (и ТОЛЬКО Instagram)
Когда я использую UIDocumentInteractionController
чтобы позволить пользователям делиться через Instagram, он работает, он вызывает опцию "открыть с помощью" и "Instagram" в качестве одного из вариантов... проблема в том, что он также отображает много других приложений, таких как "Facebook" и "Twitter"...
Есть ли способ, которым я могу сделать это только дать возможность открытия в приложении Instagram?
Instagram утверждает, что есть способ сделать это: http://instagram.com/developer/iphone-hooks/ но они упоминают это:
"Alternatively, if you want to show only Instagram in the application list (instead of Instagram plus any other public/jpeg-conforming apps) you can specify the extension class igo, which is of type com.instagram.exclusivegram."
но я, честно говоря, понятия не имею, что означает эта часть "
extension class igo
"Мой код:
UIImage *imageToUse = [UIImage imageNamed:@"imageToShare.png"];
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
docController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
docController.delegate = self;
docController.annotation = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"This is the users caption that will be displayed in Instagram"], @"InstagramCaption", nil];
docController.UTI = @"com.instagram.exclusivegram";
[docController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:self.view animated:YES];
1 ответ
Решение
Оказывается, чтобы открыть контроллер doc только в Instagram, вы просто сохраняете файл png или jpg в формате ".igo" с расширением типа файла (может быть, расшифровывается как Instagram-Only?)
Изменена третья строка кода в моем коде, чтобы вместо этого прочитать:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];
(С "иго")
и тогда это сработало!:)
Младшая версия iOS 13:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];
После iOS 13:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];