Bha*_*vik 14 iphone ios whatsapp
我在WhatsApp上使用了以下代码来共享图像,但我无法使用以下代码设置标题文本.
我已尝试过注释属性UIDocumentInteractionController
,但在WhatsApp开发人员表单中,没有为注释指定任何键.
我知道我们可以通过使用来实现UIImageGraphicContext
,但我需要将URL作为标题共享
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]])
{
NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation([UIImage imageNamed:@"Convenor- image-SURANA1.png"], 1.0) writeToFile:savePath atomically:YES];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
_documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"wwww.google.com" forKey:@"whatsappCaption"];
_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:@"Alert." message:@"Por favor, instale Whatsapp." delegate:nil cancelButtonTitle:@"Está bem" otherButtonTitles:nil];
[alert show];
}
Run Code Online (Sandbox Code Playgroud)
小智 1
NSError *error = nil;
NSURL *documentURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:&error];
UIImage *image = [UIImage imageNamed:@"share.png"];
NSURL *tempFile = [documentURL URLByAppendingPathComponent:@"whatsAppTmp.wai"];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSLog(@"%@",docDir);
NSLog(@"saving png");
NSString *pngFilePath = [NSString stringWithFormat:@"%@/test.png",docDir];
NSData *data1 = [NSData dataWithData:UIImageJPEGRepresentation(image,1.0)];
[data1 writeToFile:pngFilePath atomically:YES];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:pngFilePath]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"net.whatsapp.image";
[_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5063 次 |
最近记录: |