ios 中NSData 拼接成功,但写入本地种只有前面的data

iOS 码拜 8年前 (2016-09-19) 2170次浏览
NSData *videoData = [NSData dataWithContentsOfURL:outputFileURL];
NSLog(@”%ld”,videoData.length);
if (!self.data) {
self.data = [[NSMutableData alloc] initWithData:videoData];
}else {
//NSMutableData *newData = [NSMutableData dataWithData:videoData];

[self.data appendBytes:videoData.bytes length:videoData.length];
//[self.data appendData:videoData];
NSLog(@”self.newdata= %ld”,self.data.length);
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat:@”%@.%@”,
@”video”,@”mp4″]];

[self.data writeToFile:path atomically:NO];
NSURL *viedeoUrl = [NSURL fileURLWithPath:path];
// [self.data writeToURL:viedeoUrl atomically:NO];
NSLog(@”%ld”,[NSData dataWithContentsOfURL:viedeoUrl].length);
NSLog(@”path = %@”,viedeoUrl);

ALAssetsLibrary * library = [[ALAssetsLibrary alloc]init];
[library writeVideoAtPathToSavedPhotosAlbum:viedeoUrl completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@”%@”,assetURL);
NSLog(@”%ld”,[NSData dataWithContentsOfURL:assetURL].length);
NSLog(@”error:%@”,error);
}];

解决方案

20

20

 UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);

好吧,吧图片保存到相册,试试这个方法


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明ios 中NSData 拼接成功,但写入本地种只有前面的data
喜欢 (0)
[1034331897@qq.com]
分享 (0)