要打开 Facebook Native 配置文件,我可以使用:
NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];
有什么方法可以对 Instagram 个人资料做同样的事情吗?
最佳答案
以下代码段将使用用户名在您的设备上打开 instagram 应用。
Objective-C
NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
swift
var instagramURL: NSURL = NSURL(string: "instagram://user?username=USERNAME")
if UIApplication.sharedApplication().canOpenURL(instagramURL) {
UIApplication.sharedApplication().openURL(instagramURL)
}
swift 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
关于objective-c - 打开 Instagram Native 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16369798/