2013-10-29 2 views
0

iOS에 Tumblr 앱이있는 Tumblr에 공유 사진이 필요합니다.Tumblr을위한 UIDocumentInteractionController

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"); 

그러나 이런 식으로 어떻게 내가 찾을 수는 없지만, 텀블러에 대한 감사

답변

8
- (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;} 
에 대한 코드입니다 : 인스 타 그램에 대한

나는이 좋아해요

시도해주세요 ...! :)

0

다음은 텀블러

- (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; 
} 
관련 문제