Решение

We use cookies. Read the Privacy and Cookie Policy

Решение

Воспользуйтесь методом экземпляра writeVideoAtPathToSavedPhotosAlbum: completionBlock:, относящимся к классу ALAssetsLibrary:

#import «AppDelegate.h»

#import <AssetsLibrary/AssetsLibrary.h>

@interface AppDelegate ()

@property (nonatomic, strong) ALAssetsLibrary *assetsLibrary;

@end

@implementation AppDelegate

— (BOOL) application:(UIApplication *)application

didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

self.assetsLibrary = [[ALAssetsLibrary alloc] init];

NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"MyVideo"

withExtension:@"MOV"];

if (videoURL!= nil){

[self.assetsLibrary

writeVideoAtPathToSavedPhotosAlbum: videoURL

completionBlock: ^(NSURL *assetURL, NSError *error) {

if (error == nil){

NSLog(@"no errors happened");

} else {

NSLog(@"Error happened while saving the video.");

NSLog(@"The error is = %@", error);

}

}];

} else {

NSLog(@"Could not find the video in the app bundle.");

}

return YES;

}

Данный текст является ознакомительным фрагментом.