2015-06-19 54 views

回答

4

您可以在WhatsApp上發佈圖片或文字。但是你不會發布兩次,因爲whatsapp沒有提供任何API,你可以添加標題和文字圖像。

以下是從iPhone應用程序發佈圖像的WhatsApp與參數WhatsApp Documentation一個例子:

在ViewController.h文件

@interface ViewController : UIViewController 
{ 
} 

@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController; 

在ViewController.m文件

- (IBAction)bocClick:(UIButton *)sender { 


    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 

    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; //here i am fetched image path from document directory and convert it in to URL and use bellow 


    NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath]; 
    NSLog(@"imag %@",imageFileURL); 

    self.documentationInteractionController.delegate = self; 
    self.documentationInteractionController.UTI = @"net.whatsapp.image"; 
    self.documentationInteractionController = [self setupControllerWithURL:imageFileURL usingDelegate:self]; 
    [self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; 


} 

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL 

               usingDelegate: (id) interactionDelegate { 



    self.documentationInteractionController = 

    [UIDocumentInteractionController interactionControllerWithURL: fileURL]; 

    self.documentationInteractionController.delegate = interactionDelegate; 



    return self.documentationInteractionController; 

} 
相關問題