2011-10-27 14 views
5

私はビデオを録画するアプリケーションを持っています。しかし、録画が終了したらすぐにビデオを保存することはできません。私は最初に合意を示す必要があります。だから、私はイメージピッカーから取得するURLを保存しようとします。後でライブラリにビデオを保存します。 これはiOS4では問題なく動作しましたが、iOS5では正常に動作しませんでした。 私はiOSとObjective-Cを初めて使いました。そのため、URLを保持するはずのプロパティの宣言が間違っている可能性があります。ライブラリに保存するための録画ビデオURLを後で保存する

これは、コードの一部です:didFinishPickingMediaWithInfoがあるときに、ログから

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

} 

出力:から

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

出力dを記録するsaveMyVideo "を選択します。 URLが突然これに変わりました!! :

saving movie at: (
"0.31269", 
"0.32899", 
"0.63999", 
"0.33001", 
"0.3", 
"0.6", 
"0.15", 
"0.05999" 
) 

答えて

0

(。質問の編集にOPで回答Question with no answers, but issue solved in the comments (or extended in chat)を参照してください)

ザ・OPは書いた:

を間違ったコードはでした:

tempMoviePath = moviePath; 

私は宣言されたプロパティを設定しているので、私はセット&メソッドを取得します。それは次のようになります。

[self setTempMoviePath:moviePath]; 

どうやらのiOS 4は、この上でそれほど難しいことではありませんでしたが、iOS5を、それを扱うことができません。しかし、とにかく、それはそのような書き方が間違っていた。私は間違いを認めます。 :)

関連する問題