Я думаю, что ваша фотография или URL файла неверны.Я успешно сделал это с помощью следующего фрагмента кода:
в вашем файле .h:
@property (nonatomic, retain) UIDocumentInteractionController *docDic;
и добавьте в ваш следующий делегат:
UIDocumentInteractionControllerDelegate
.m файл:
синтезировать объект docDic
Написать следующий метод:
-(UIDocumentInteractionController *)setupControllerWithURL:(NSURL*)fileURL usingDelegate:(id<UIDocumentInteractionControllerDelegate>)interactionDelegate{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
Затем добавьте следующий фрагмент кода в функцию shareToInstagram:
NSString * fileToOpen = [[NSBundle mainBundle] pathForResource: @ "IMG_0192" ofType: @ "jpg"];
fileToOpen =[fileToOpen substringToIndex: [длина fileToOpen] - 3];
fileToOpen = [NSString stringWithFormat: @ "% @. ig", fileToOpen];
NSURL * instagramURL = [[NSURL alloc]initWithString: [[NSString alloc] initWithFormat: @ "file: //% @", fileToOpen]];
if ([[UIApplication sharedApplication] canOpenURL: instagramURL]) {
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToOpen]];
self.documentInteractionController.UTI = @ "com.instagram.photo";
[self.dic presentOpenInMenuFromRect: CGRectZero inView: self.viанимация: ДА];}
Надеюсь, это поможет вам.Удачи.: -)