如何在按钮点击时打开Instagram应用程序

  1. 大家好我正在尝试按下按钮点击打开Instagram应用程序,但我无法将pll方案设置为plist中的instagram

    NSString *instagramURL = @"instagram://app"; NSURL *ourURL = [NSURLURLWithString:instagramURL]; if ([[UIApplication sharedApplication]canOpenURL:ourURL]) { [[UIApplication sharedApplication]openURL:ourURL]; } else { //The App is not installed. It must be installed from iTunes code. NSString *iTunesLink = @"//Some other Url goes here"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"URL error" message:[NSString stringWithFormat: @"No custom URL defined for %@", ourURL] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; 

    我确实喜欢这个但应用程序没有打开iOS新任何帮助可以欣赏

你可以通过用户名打开instagram app,

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

你可以参考Instagram的iPhone Hooks了解更多关于api的方法和细节!

更新:

替换下面的行,

  NSString *instagramURL = @"instagram://app"; 

  NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; 

你直接指定字符串为url !!

在Info.plist文件中添加键值

 LSApplicationQueriesSchemes  instagram twitter