我正在使用这种方法进行屏幕截图:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*theImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);
我想获取该照片的路径,以便我可以将其与 Instagram 方法一起使用
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat"file://%@", lastphotoTaken]];
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat"file://%@", lastphotoTaken]];
self.dic.UTI = @"com.instagram.exclusivegram";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.dic.annotation = [NSDictionary dictionaryWithObject"Here Give what you want to share" forKey"InstagramCaption"];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
感谢
无法使用以下方法获取 Assets 网址:
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);
您可以使用:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[theImageCGImage] orientationALAssetOrientation)[theImageimageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){
if (error)
{
NSLog(@"Ooops!");
}
else
{
NSLog(@"Saved URL : %@", assetURL);
}
}];
[library release];
关于ios - 如何从照片库中获取最后一张照片的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19733210/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |