【问题标题】:How to insert tag with photo for Instagram sharing如何插入带有照片的标签以进行 Instagram 共享
【发布时间】:2014-02-25 18:11:04
【问题描述】:

我将照片分享到 Instagram,一些应用程序通过照片插入标签,我该怎么做?

- (void)instagramWithImage:(UIView*)view openInView:(UIViewController*)viewCont

 {

            UIView* captureView = view;


        /* Capture the screen shoot at native resolution */
        UIGraphicsBeginImageContextWithOptions(captureView.bounds.size, NO, 0.0);
        [captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();


        /* Render the screen shot at custom resolution */
        CGRect cropRect = CGRectMake(0 ,0 ,1024 ,1024);
        UIGraphicsBeginImageContextWithOptions(cropRect.size, NO, 1.0f);
        [screenshot drawInRect:cropRect];
        UIImage * customScreenShot = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();


        NSURL *url;
        docFile.delegate = self;

        //Save image to directory
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.jpg"];


        UIImage *image = customScreenShot;

        NSData *imageData = UIImagePNGRepresentation([image imageByApplyingSharpen3x3]);
        [imageData writeToFile:savedImagePath atomically:NO];

        //load image
        NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.jpg"];
        UIImage *tempImage = [UIImage imageWithContentsOfFile:getImagePath];

        //Hook it with Instagram
        NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Image.ig"];
        [UIImageJPEGRepresentation(tempImage, 1.0) writeToFile:jpgPath atomically:YES];

        url = [[NSURL alloc] initFileURLWithPath:jpgPath];
        docFile = [UIDocumentInteractionController interactionControllerWithURL:url];
        [docFile setUTI:@"com.instagram.photo"];

     CGRect rect = viewCont.view.bounds;
        [docFile presentOpenInMenuFromRect:rect inView:viewCont.view animated:YES];



}

【问题讨论】:

  • 你在 Instagram 上发布的代码是什么?
  • @Larme 检查我编辑的问题

标签: ios iphone objective-c instagram


【解决方案1】:

可以使用 UIDocumentInteractionController 的 annotation 属性来设置标题

documentInteractionController.annotation = @{@"InstagramCaption" : @"yourCustomTag" };

更多信息:Instagram Documentation Source

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多