【发布时间】:2014-03-03 15:01:41
【问题描述】:
在我的应用程序中,我设法通过文档交互控制器将图像发布到 Instagram。这一个还显示了在 Dropbox、whatsapp 等上共享的选项。我不想要这些功能,我只想要 Instagram。有没有办法以编程方式单击 Instagram 按钮,或删除其他不需要的应用程序的按钮? 提前感谢您的回答。
编辑:这是代码,其中包含“com.instagram.exclusivegram”的行我设法只显示了 Instagram、Bump 和 Dropbox。我怎样才能让最后两个消失?
-(void)ShareInstagram
{
[self storeimage];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
CGRect rect = CGRectMake(0 ,0 , 612, 612);
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/15717.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
_dic.UTI = @"com.instagram.exclusivegram";
_dic.delegate=self;
_dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
_dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
_dic.delegate=self;
[_dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
// [[UIApplication sharedApplication] openURL:instagramURL];
}
else
{
// NSLog(@"instagramImageShare");
UIAlertView *errorToShare = [[UIAlertView alloc] initWithTitle:@"Instagram unavailable " message:@"You need to install Instagram in your device in order to share this image" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
errorToShare.tag=3010;
[errorToShare show];
}
}
- (void) storeimage
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"15717.igo"];
UIImage *NewImg=[self resizedImage:_imageToTweet inImage:CGRectMake(0, 0, 612, 612) ];
NSData *imageData = UIImagePNGRepresentation(NewImg);
[imageData writeToFile:savedImagePath atomically:NO];
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
interactionController.delegate = self;
return interactionController;
}
【问题讨论】:
-
使用
UIDocumentInteractionController的全部意义在于让用户决定要做什么。如果您只想要 Instragram,请使用不同的解决方案。在这里做一些搜索。有很多关于直接发布到 Instagram 的现有主题。 -
我没有找到任何关于直接发布的信息。你能帮我一些链接吗?谢谢。
-
@charles,你有没有找到只显示 Instagram 的解决方案?
-
@rmaddy 除了使用
UIDocumentInteractionController,别无他法,别再误导人了。
标签: ios instagram uidocumentinteraction