首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Tumblr的UIDocumentInteractionController

Tumblr的UIDocumentInteractionController
EN

Stack Overflow用户
提问于 2013-10-29 02:48:10
回答 2查看 613关注 0票数 0

我需要分享照片在Tumblr,与应用程序Tumblr在iOS。

对于instagram,我确实喜欢这样:

代码语言:javascript
运行
复制
  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,谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-08-11 05:21:31

代码语言:javascript
运行
复制
- (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;}

试试这个.!)

票数 8
EN

Stack Overflow用户

发布于 2014-02-13 09:20:49

以下是tumblr的代码

代码语言:javascript
运行
复制
- (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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19648766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档