当我编写下面提到的代码时,我得到了这个错误。基本上我想将UIImagePickerController捕获的视频保存到我的app目录。我没有弄到错误的地方。请帮助我..
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:NO]; // Handle a movie capture if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; NSString *movieName = [NSString stringWithFormat:@"%@.mov",[self getNameForVideo]]; NSString *moviePath = [documentsDir stringByAppendingPathComponent:movieName]; NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL]; NSData * movieData = [NSData dataWithContentsOfURL:movieURL]; if([movieData writeToFile:moviePath atomically:NO]) { [self saveVideoInfoInDatabase]; } else { NSLog(@"Video could not be saved to the document directry"); } } }
答案 0 :(得分:1)
这是内存限制的原因(以各种方式表现出来)。它也可能是下载完成和当时UI之间的线程交互行为的原因。有些人表示,显示UIAlertView并创建UIWebView时存在问题,后者是在前者之前创建的。 如果您有快速下载连接(在模拟器和本地Web服务器中可能就是这种情况),那么您可能会发现下载完成得太快,UI无法准备好显示通知下载已完成。