存储录制的视频URL以便稍后保存到库

use*_*010 5 uiimagepickercontroller ios5

我有一个录制视频的应用程序.但录制完成后,我无法立即保存视频.我需要先达成协议.所以我尝试保存从图像选择器获得的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;
Run Code Online (Sandbox Code Playgroud)

.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]; 

}
Run Code Online (Sandbox Code Playgroud)

didFinishPickingMediaWithInfo时日志的输出是:

temp movie path: file://localhost/private/var/mobile/Applications/8CFD1CB7-70A0-465C-B730-817ACE5A4F78/tmp/capture-T0x119660.tmp.hNFzkY/capturedvideo.MOV
Run Code Online (Sandbox Code Playgroud)

在执行"saveMyVideo"时从日志输出.网址突然变成了!! :

saving movie at: (
"0.31269",
"0.32899",
"0.63999",
"0.33001",
"0.3",
"0.6",
"0.15",
"0.05999"
)
Run Code Online (Sandbox Code Playgroud)

Bri*_*汤莱恩 0

(OP在问题编辑中回答。请参阅没有答案的问题,但问题在评论中解决(或在聊天中扩展)

OP 写道:

错误的代码是:

tempMoviePath = moviePath;
Run Code Online (Sandbox Code Playgroud)

因为我要设置声明的属性,所以我必须使用 set 和 get 方法。它应该是:

[self setTempMoviePath:moviePath];
Run Code Online (Sandbox Code Playgroud)

显然 iOS 4 在这方面并没有那么难,但 iOS5 却无法处理。但无论如何,这样写是错误的。我承认我的错误。:)