2013-05-04 41 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