2016-09-26 2 views
0

Im работает с функцией обмена фотографиями с Instagram с быстрым 2.2 и работает на iOS9, но не с iOS10, есть ли разница между iOS9 и iOS10? Вот как я достигаю этого на iOS9, спасибо за любые советы.iOS10 swift 2.2 share on Instagram openURL & canOpenURL change

class viewController: UIViewController, UIDocumentInteractionControllerDelegate { 

var yourImage: UIImage? 
var documentController: UIDocumentInteractionController! 

func shareToInstagram() { 

let instagramURL = NSURL(string: "instagram://app") 

     if (UIApplication.sharedApplication().canOpenURL(instagramURL!)) { 

      let imageData = UIImageJPEGRepresentation(yourImage!, 100) 

      let captionString = "caption" 

     let writePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("instagram.igo") 
     if imageData?.writeToFile(writePath, atomically: true) == false { 

       return 

      } else { 
let fileURL = NSURL(fileURLWithPath: writePath) 

       self.documentController = UIDocumentInteractionController(URL: fileURL) 

       self.documentController.delegate = self 

       self.documentController.UTI = "com.instagram.exlusivegram" 

       self.documentController.annotation = NSDictionary(object: captionString, forKey: "InstagramCaption") 
         self.documentController.presentOpenInMenuFromRect(self.view.frame, inView: self.view, animated: true) 

      } 

     } else { 
      print(" Instagram isn't installed ") 
     } 
    } 
+0

Как это не удается? Вы получили сообщение об ошибке? Это терпит неудачу? –

+0

Привет @NicolasMiari, это просто ответ, когда я пытаюсь поделиться фотографией с instagram на устройстве iOS 10. Да, это терпит неудачу, приложение все еще работает после этого. –

ответ

0

Проблема решена, просто обновите до xcode8 и с помощью swift2.3.

Смежные вопросы