从Swift打开Instagram图片

时间:2015-03-05 16:02:15

标签: ios objective-c swift instagram nsurl

代码似乎选择了正确的变量,但从未打开Instagram应用程序来显示该图像。

func showOriginWebPage() {

    println("showOriginWebPage: \(self.id!)")

    if let appURL = NSURL(string: "instagram://media?id=\(self.id)") {
        let canOpen = UIApplication.sharedApplication().canOpenURL(appURL)
    }
}

// println: showOriginWebPage: 932481051119413840_1563069185

感谢任何指针。

enter image description here

1 个答案:

答案 0 :(得分:0)

我是这样做的

@IBAction func openOnInstagramAction(sender: AnyObject) {

    var instagramURL = NSURL(string: "instagram://user?id=" + "1234567890" )
    if (UIApplication.sharedApplication().canOpenURL(instagramURL!)) {
        UIApplication.sharedApplication().openURL(instagramURL!)
    }else {
        println("Instagram not installed")
    }
}