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

时间:2011-10-22 10:11:33

标签: iphone

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

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

委托,但它反映了当前的日期和时间。

1 个答案:

答案 0 :(得分: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时分配和释放格式化程序。

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

相关问题