Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Tumblr的UIDocumentInteractionController_Ios_Iphone_Tumblr_Sharing - Fatal编程技术网

Ios Tumblr的UIDocumentInteractionController

Ios Tumblr的UIDocumentInteractionController,ios,iphone,tumblr,sharing,Ios,Iphone,Tumblr,Sharing,我需要在Tumblr中共享照片,并在iOS中使用应用程序Tumblr 对于instagram,我喜欢这样: NSData *imageData = UIImageJPEGRepresentation(self.test.image, 1.0); NSString *writePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"]; if (![imageData writ

我需要在Tumblr中共享照片,并在iOS中使用应用程序Tumblr

对于instagram,我喜欢这样:

  NSData *imageData = UIImageJPEGRepresentation(self.test.image, 1.0);

    NSString *writePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"];
    if (![imageData writeToFile:writePath atomically:YES]) {
        NSLog(@"image save failed to path %@", writePath);
        return;
    } 

    // send it to instagram.
    NSURL *fileURL = [NSURL fileURLWithPath:writePath];
    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    [self.documentController setUTI:@"com.instagram.exclusivegram"];
    [self.documentController setAnnotation:@{@"InstagramCaption" : @"#hey"}];

    if (![self.documentController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES]) NSLog(@"couldn't present document interaction controller");

但是我找不到这样做的方法,但是对于Tumblr,谢谢

下面是Tumblr的代码

- (IBAction)tumblrButtonTapped:(id)sender {    
    NSString * documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString * savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"tumblrImage.jpg"];
    [UIImageJPEGRepresentation(image, 1.0) writeToFile:savedImagePath atomically:YES]; //Put image here

    NSURL * imageUrl = [NSURL fileURLWithPath:savedImagePath];
    docController = [[UIDocumentInteractionController alloc] init];
    docController.delegate = self;

    docController.UTI = @"com.tumblr.photo";
    [docController setURL:imageUrl];
    [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}

-(UIViewController*) documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller{
    return self;
}

-(UIDocumentInteractionController *) setupControllerWithURL:(NSURL *)fileURL
                                          usingDelegate:(id <UIDocumentInteractionControllerDelegate>)         interactionDelegate {
    UIDocumentInteractionController *interactionController =
    [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    interactionController.delegate = interactionDelegate;

    return interactionController;
}
试试这个…!:

- (IBAction)btn_tumblr:(id)sender{

CGRect rect =  CGRectMake(0, 0, 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.frame.size,self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();

[UIImageJPEGRepresentation(getShareimage, 1.0) writeToFile:[NSString stringWithFormat:@"%@/%@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"],@"photo.tumblrphoto"] atomically:YES];
NSURL *fileURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"],@"photo.tumblrphoto"]]; 
self.dic.delegate = self;
self.dic.UTI = @"com.tumblr.photo";
[self setupControllerWithURL:fileURL usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:fileURL];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];}


- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;}