- (void)viewDidLoad {
[super viewDidLoad];
NSFileManager *fileManager = [NSFileManager defaultManager];
// 導入圖片
NSString *picPath = [[NSBundle mainBundle] pathForResource:@"Pic" ofType:@"bundle"];
NSDirectoryEnumerator *picEnumerator = [fileManager enumeratorAtPath:picPath];
NSString *picBundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Pic.bundle"];
while((picPath = [picEnumerator nextObject]) != nil) {
NSString *itemPicPath = [NSString stringWithFormat:@"%@/%@", picBundlePath, picPath];
UIImage *image = [UIImage imageWithContentsOfFile:itemPicPath];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
// 導入視頻
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"Video" ofType:@"bundle"];
NSString *videoBundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Video.bundle"];
NSDirectoryEnumerator *videoEnumerator = [fileManager enumeratorAtPath:videoPath];
while ((videoPath = [videoEnumerator nextObject]) != nil) {
NSString *itemVideoPath = [NSString stringWithFormat:@"%@/%@", videoBundlePath, videoPath];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(itemVideoPath)) {
UISaveVideoAtPathToSavedPhotosAlbum(itemVideoPath, nil, nil, nil);
}
}
}