一起發佈instagram我通過文檔交互控制器管理將圖像發佈到Instagram。這也顯示了Dropbox,WhatsApp等共享選項。我不想要這些功能,我只想要Instagram。有沒有辦法以編程方式點擊Instagram按鈕,或刪除其他不需要的應用程序的按鈕? 預先感謝您的回答。在我的應用程序中直接與文檔交互控制器
編輯:這裏是代碼,包含「com.instagram.exclusivegram」的行,我設法只顯示Instagram,凹凸和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的現有話題很多。 – rmaddy
我沒有找到關於直接發佈的任何信息。你能幫我一些鏈接嗎?謝謝。 – charles
@charles,你有沒有找到解決方案,只顯示Instagram的? – Abhishek