ios - UIActivityViewController sharing image via email has no extension -
the image attached "attachment-1", no extension. how specify 1 ?
nsdata *compressedimage = uiimagejpegrepresentation(self.resultimage, 0.8 ); uiactivityviewcontroller *activityviewcontroller = [[uiactivityviewcontroller alloc] initwithactivityitems:@[ @"check out!", compressedimage ] applicationactivities:nil]; [self.navigationcontroller presentviewcontroller:activityviewcontroller animated:yes completion:nil];
according this answer should able use workaround specify filename
nsdata *compressedimage = uiimagejpegrepresentation(self.resultimage, 0.8 ); nsstring *docspath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *imagepath = [docspath stringbyappendingpathcomponent:@"image.jpg"]; nsurl *imageurl = [nsurl fileurlwithpath:imagepath]; [compressedimage writetourl:imageurl atomically:yes]; // save file uiactivityviewcontroller *activityviewcontroller = [[uiactivityviewcontroller alloc] initwithactivityitems:@[ @"check out!", imageurl ] applicationactivities:nil];
the obvious drawback of approach have save image on disk.
Comments
Post a Comment