すぐにサンプルアプリケーションを実行しています。私は自分のアプリから画像を共有する必要があります。 Social framework
の助けを借りて、Facebook
とTwitter
を統合しました。今、私は私が[のWhatsAppへのWhatsAppにインポートまたはコピー]を選択した場合Instagram
とWhatsApp
iOS:ソーシャルネットワークで画像を共有するSwift
シェアボタンアクション
@IBAction func shareAcn(sender: UITapGestureRecognizer) {
var documentController: UIDocumentInteractionController!
let fileURL = NSBundle.mainBundle().pathForResource("smc", ofType: "png")
documentController = UIDocumentInteractionController.init(URL: NSURL(fileURLWithPath: fileURL!))
documentController.presentOptionsMenuFromRect(CGRectZero, inView: self.view, animated: true)
}
と統合する方法のWhatsApp
@IBAction func shareAcn(sender: UITapGestureRecognizer) {
var documentController: UIDocumentInteractionController!
let image = UIImage(named: "smc")
let filename = "myimage.wai"
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, false)[0] as NSString
let destinationPath = documentsPath.stringByAppendingString("/" + filename)
UIImagePNGRepresentation(image!)!.writeToFile(destinationPath, atomically: false)
let fileURL = NSURL(fileURLWithPath: destinationPath) as NSURL
documentController = UIDocumentInteractionController.init(URL: fileURL)
documentController.UTI = "net.whatsapp.image"
documentController.presentOptionsMenuFromRect(CGRectZero, inView: self.view, animated: true)
}
を知らないアプリ墜落するWhatsApp
を選択した場合、「このアイテムは送信できません」。
Instagramの
var instagramURL: NSURL = NSURL(string: "instagram://user?username=USERNAME")
if UIApplication.sharedApplication().canOpenURL(instagramURL) {
UIApplication.sharedApplication().openURL(instagramURL)
}
コードはいずれも作業していません。
私はInstagram
をインストールし、私のテストデバイスに私のユーザとしてログオンしています。実行すると、Instagram
は開かれません。
私はこれを解決する方法を知らないのですか?親切に私を導く。
参照:http://stackoverflow.com/a/30988328/1457385 – shallowThought
LSApplicationsQueriesSchemes? Info.plistはどこにありますか?私はそれを見つけることができません。 –
if文の中にブレークポイントを置くと、これまでにヒットしますか? – colinrf