简体   繁体   English

如何从照片库获取上一张照片的路径?

[英]How do i get last photo's path from photo library?

i'm using this method to take screen capture : 我正在使用这种方法进行屏幕捕获:

    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*theImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);

and i want to get path for that photo so i can use it with Instagram methods 我想获取该照片的路径,以便可以将其与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 ];

thanx 感谢名单

There is no way to get the asset url using: 无法使用以下方法获取资产网址:

UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);

Instead you can use: 相反,您可以使用:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

[library writeImageToSavedPhotosAlbum:[theImageCGImage] orientation:(ALAssetOrientation)[theImageimageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){  
    if (error)
    {  
        NSLog(@"Ooops!");  
    }
    else
    {  
        NSLog(@"Saved URL : %@", assetURL);  
    }  
}];  
[library release];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift - 如何从照片库中获取最后拍摄的 3 张照片? - Swift - how to get last taken 3 photos from photo library? 如何在照片库中获取最新照片的路径? (作为NSUrl或字符串) - How do I get the path to the most recent photo in the photos library? (As a NSUrl or string) 如何通过应用程序从设备的图片库中删除照片? - How to delete photo from the Photo's Library of device through the application? 如何从ALASSET的照片库中获取第一张(最近的)照片? - How do get the first(most recent) photo from the Photo Library in ALASSET? 从照片库获取照片不起作用 - Get a photo from photo library not working 如何从iOS照片库中获取图像并将其显示在UIWebView中 - How do I get an image from the iOS photo library and display it in UIWebView 如何从手机库中获取照片? - How do I get a photo from the phone gallery? 从照片库获取图像,然后按名称和路径将其上传到Web服务 - Get an image from photo library and upload it to web service by name and path 如何从iOS / iPhone中的资产库获取照片/视频源路径? - How to get photo/video origin path from assets-library in iOS/iPhone? 如何使用URL路径从iOS的照片库中获取图像? - How to fetch an image from photo library of iOS using URL path?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM