我試圖在錄製文件後將文件夾中的影片保存到文件夾中。將記錄的視頻保存到文檔文件夾中
這是我的代碼:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
[self dismissViewControllerAnimated:YES completion:nil];
NSLog(@"path from image picker: %@", moviePath);
NSFileManager* fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString* documentsDir = [paths objectAtIndex:0];
NSLog(@"%@",documentsDir);
[fileManager moveItemAtPath:moviePath toPath:documentsDir error:nil];
NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDir
error:nil];
for (id object in files) {
NSLog(@"%@",object);
}
}
正如你可能猜到了,這是行不通的。
第一個日誌說:從圖片選擇路徑:/private/var/mobile/Applications/6630FBD3-1212-4ED0-BC3B-0C23AEEFB267/tmp/capture-T0x1e575330.tmp.SQQ2C5/capturedvideo.MOV
秒記錄說:/ var/mobile/Applications/6630FBD3-1212-4ED0-BC3B-0C23AEEFB267/Documents
任何人都知道爲什麼它不工作?
檢查我的答案,保存視頻到目錄我已更新它。 – 2013-04-29 08:12:23