【发布时间】:2011-10-27 09:32:11
【问题描述】:
我有一个录制视频的应用程序。但是录制完成后,我无法立即保存视频。我需要先出示一份协议。所以我尝试保存从图像选择器获得的 URL。稍后将视频保存到库中。 这在 iOS4 中运行良好,但在 iOS5 中不行。 我是 iOS 和 Objective-C 的新手,所以我可能对应该保存 URL 的属性做了一些完全错误的声明。
这是部分代码:
.h
#import <UIKit/UIKit.h>
#import <AssetsLibrary/AssetsLibrary.h>
@interface Video_recViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate> {
NSURL *tempMoviePath;
}
@property (nonatomic, retain) NSURL *tempMoviePath;
.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *moviePath = [info objectForKey:UIImagePickerControllerMediaURL];
[self dismissModalViewControllerAnimated: YES];
NSLog(@"path from image picker: %@", moviePath);
tempMoviePath = moviePath;
NSLog(@"temp movie path: %@", tempMoviePath);
//
[self performSelector:@selector(showAgree) withObject:nil afterDelay:0.5];
}
- (void)userAgreed {
NSLog(@"user agreed");
//NSLog(@"temp movie path: %@", tempMoviePath);
[self saveMyVideo:tempMoviePath];
//[self performSelector:@selector(showSurvey) withObject:nil afterDelay:0.5];
}
- (void)saveMyVideo:(NSURL *)videoURL {
NSLog(@"saving movie at: %@", videoURL);
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL])
{
[library writeVideoAtPathToSavedPhotosAlbum:videoURL
completionBlock:^(NSURL *assetURL, NSError *error){}
];
}
[library release];
}
didFinishPickingMediaWithInfo 为时的日志输出:
temp movie path: file://localhost/private/var/mobile/Applications/8CFD1CB7-70A0-465C-B730-817ACE5A4F78/tmp/capture-T0x119660.tmp.hNFzkY/capturedvideo.MOV
执行“saveMyVideo”时从日志中输出。网址突然变成了这个!! :
saving movie at: (
"0.31269",
"0.32899",
"0.63999",
"0.33001",
"0.3",
"0.6",
"0.15",
"0.05999"
)
【问题讨论】:
标签: ios5 uiimagepickercontroller