2013-05-04 36 views
5

要打开Facebook的本地配置文件,我可以使用:打开链接到Instagram的本地

NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"]; 
[[UIApplication sharedApplication] openURL:url]; 

有没有办法做同样的事情的Instagram的个人资料?

回答

23

下面的代码片段将打开Instagram的应用程序在设备上使用的用户名。

目标C

NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"]; 
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { 
    [[UIApplication sharedApplication] openURL:instagramURL]; 
} 

斯威夫特

var instagramURL: NSURL = NSURL(string: "instagram://user?username=USERNAME") 
if UIApplication.sharedApplication().canOpenURL(instagramURL) { 
    UIApplication.sharedApplication().openURL(instagramURL) 
} 

雨燕3.0

如果您想了解更多
let instagramURL:URL = URL(string: "instagram://user?username=USERNAME")! 
if UIApplication.shared.canOpenURL(instagramURL) { 
    UIApplication.shared.open(instagramURL, options:[:], completionHandler: { (Bool) in 
     print("Completion block") 
    }) 
} 

有关它的详细信息,您可以参考以下内容Documentation link

+0

我们如何获取用户名和用户电子邮件ID等个人资料信息?任何人都可以解决此问题 – sabir 2014-01-30 12:40:18

+0

请通过此链接,您将在Instagram文档中获得您的答案http:// instagram.com/developer/authentication/# – 2014-01-31 04:37:42

+0

你有任何样品可以请你寄给我很新的IOS – sabir 2014-02-04 09:20:34