我将在编码的帮助下在whatsapp中添加图像和一些文本。我怎样才能解决我的问题?
答案 0 :(得分: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;
}