gpt4 book ai didi

ios - 我如何从照片库中获取最后一张照片的路径?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:39:12 26 4
gpt4 key购买 nike

我正在使用这种方法进行屏幕截图:

    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 url:

UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);

相反,您可以使用:

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];

关于ios - 我如何从照片库中获取最后一张照片的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19733210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com