我有一个应用程序,在其中分享图片到Instagram,它能够正常工作。如截图所示,当我点击分享到Instagram按钮时,它会在UIActivityViewController中打开。
是否可能,如果我点击分享到Instagram,直接进入本机的Instagram应用程序?
如果用户在设备上安装了其他应用程序,则由于UIActivityViewController,这些应用程序也会显示。
我不想显示UIActivityViewController,并说“在Instagram中打开”。
提前致谢。
编辑
我正在截取视图并分享该截图到Instagram。
当我点击分享按钮时,它会打开如截图所示的界面,但我不想要这样。
我正在使用以下代码。
NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
imagename=[NSString stringWithFormat:@"ff.ig"];
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imagename];
////NSLog(@"%@",fullPathToFile);
igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", fullPathToFile]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.dic.annotation = [NSDictionary dictionaryWithObject:@"Image" forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect: rect inView:self.view animated: YES ];
}