在iOS中,我想使用开关将图像移动到特定的位置,当开关打开时,它会将图像移动到我指定的位置,当它关闭时,它会移动到它来自的位置。
发布于 2014-12-19 15:25:08
你可以使用下面的函数将所有的图片move到新的Path中。
只需对DirectoryPath Old和New执行pass操作
- (void)moveFileFromFolder:(NSString *)oldFolderPath toFolder:(NSString *)newFolderPath {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *fileNames = [fileManager contentsOfDirectoryAtPath:oldFolderPath error:nil];
for (NSString *fileName in fileNames) {
NSString * oldFilePath = [oldFolderPath stringByAppendingString:fileName];
NSString * newFilePath = [newFolderPath stringByAppendingString:fileName];
NSError *error = nil;
[fileManager moveItemAtPath:oldFilePath toPath:newFilePath error:&error];
if (error) {
NSLog(@"error = %@", [error description]);
return;
}
}
}https://stackoverflow.com/questions/27561356
复制相似问题