首页 文章

如何获取使用iphone创建视频的日期和时间?

提问于
浏览
0

我需要根据创建日期和时间对视频进行分类 . 我尝试使用ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset * myasset){CLLocation * location = [myasset valueForProperty:ALAssetPropertyLocation];

in(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

代表,但它反映了当前的日期和时间 .

1 回答

  • 0

    在上面的代码示例中,看起来您正在尝试获取经度和纬度 . :-)

    要获取ALAsset的日期和时间,只需执行以下操作即可;

    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd-MM-yyyy 'at' HH:mm"];
        NSDate * dateFileCreated = [theAsset valueForProperty: @"ALAssetPropertyDate"];
    
        NSLog( @"date for this file is %@ %@", [[[theAsset defaultRepresentation] url] absoluteString], [dateFormatter stringFromDate: dateFileCreated] );
        [dateFormatter release];
    

    我在其中放置了日期格式化程序,因此您可以在控制台日志中查看日期,但在发布代码中,您可能不希望在枚举ALAssets时分配和释放格式化程序 .

    希望这些信息可以帮到你!

相关问题