这是不起作用的zip文件:http://jmp.sh/v/w4gE5SXNiRd0d7tasc3U
这是现在可以正常工作的zip文件:http://jmp.sh/v/tzyJU3nlc1qOPI9ZzDTF
- (voID)imagePickerController:(UIImagePickerController *)picker dIDFinishPickingMediawithInfo:(NSDictionary *)info { Nsstring *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; // Handle a movIE capture if (CFStringCompare((__brIDge_retained CFStringRef)mediaType,kUTTypeMovIE,0) == kcfCompareEqualTo) { Nsstring *movIEPath = [Nsstring stringWithFormat:@"%@",[[info objectForKey:UIImagePickerControllerMediaURL] path]]; NSURL *vIDeoURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSData *vIDeoData = [NSData dataWithContentsOfURL:vIDeoURL]; AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; _managedobjectContext = [appDelegate managedobjectContext]; VIDeo *vIDeo = [NSEntityDescription insertNewObjectForEntityForname:@"VIDeo" inManagedobjectContext:_managedobjectContext]; ; NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES); Nsstring *documentsDirectory = [paths objectAtIndex:0]; int random = arc4random() % 1000; //[documentsDirectory stringByAppendingFormat:@"/vID1.mp4"] Nsstring *tempPath = [documentsDirectory stringByAppendingPathComponent: [Nsstring stringWithFormat:@"vID%d%@%@.mp4",random,self.currentAthlete.first,self.currentAthlete.last]]; BOol success = [vIDeoData writetofile:tempPath atomically:NO]; if (success == FALSE) { NSLog(@"VIDeo was not successfully saved."); } else{ ]; } NSError *error = nil; if (![_managedobjectContext save:&error]) { } if (UIVIDeoAtPathIsCompatibleWithSavedPhotosAlbum(movIEPath)) { UISaveVIDeoAtPathToSavedPhotosAlbum(movIEPath,self,@selector(vIDeo:dIDFinishSavingWithError:contextInfo:),nil); } } [self dismissVIEwControllerAnimated:YES completion:nil]; }解决方法 不要创建这样的路径:
Nsstring *tempPath = [Nsstring stringWithFormat:@"%@/vID%d%@%@.mp4",documentsDirectory,self.currentAthlete.last];
像这样创建:
Nsstring *tempPath = [documentsDirectory stringByAppendingPathComponent: [Nsstring stringWithFormat:@"vID%d%@%@.mp4",self.currentAthlete.last]];总结
以上是内存溢出为你收集整理的ios – 将视频URL保存到Core Data全部内容,希望文章能够帮你解决ios – 将视频URL保存到Core Data所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)