2014-12-05 122 views
0

我想知道如何在什麼應用上共享多個媒體文件。 如果已經有相同的問題,請指導我。 這裏是我使用的文本此代碼非常適用於發送文本代碼,在WhatsApp上共享多媒體文件(音頻/視頻/圖像)

- (void)WhatsAppClicked 
{ 
    NSString *textwithTitle=[NSString stringWithFormat:@"-%@\n\n%@",LS_detailTitleLabel.text,LS_detailTextView.text]; 
    NSString *textURL=[NSString stringWithFormat:@"whatsapp://send?text=%@",textwithTitle];//make string 
    textURL=[textURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];//now make string look like URL 
    NSURL *whatsappURL = [NSURL URLWithString:textURL];//now pass it into URL 
    if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) 
    { 
     [[UIApplication sharedApplication] openURL: whatsappURL]; 
    } 
    else 
    { 
     UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"WhatsApp Error...!" message:@"WhatsApp Might not installed on your phone.Install it and try again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [alert show]; 
    } 
} 

。 在此先感謝。

回答

0

試試這個代碼共享您的圖像

這裏image_share是要分享

-(void)whatsappShare 
{ 
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]) 
{ 
    UIImage *iconImage = image_share; 
    NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"]; 

    [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES]; 

    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]]; 
    _documentInteractionController.UTI = @"net.whatsapp.image"; 
    _documentInteractionController.delegate = self; 

    [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES]; 
} 
else 
{ 
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Please Install WhatsApp Application to share" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue",nil]; 
    [alert show]; 
} 
} 
+0

請在多個共享提供指導你的形象。 – Vats 2014-12-05 07:42:35

+0

對不起大桶,我對此沒有任何想法 – Velu 2014-12-05 08:04:38