2014-12-19 14 views

Odpowiedz

4

możesz użyć następującej funkcji do move wszystkich swoich zdjęć do nowej Path.

Trzeba pass właśnie zarówno DirectoryPathOld i New

- (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; 
     } 
    } 
} 
+0

i jak mogę dostać ścieżka mam [kod] (http://dpaste.com/3G6WE6P)? –

+0

'UIImagePickerControllerOriginalImage' zwraca tylko dane obrazu, bez odniesienia do lokalnej pamięci. Nie użyłem go samodzielnie, ale domyślam się, że to, czego szukasz, to: NSURL * localUrl = (NSURL *) [info valueForKey: UIImagePickerControllerReferenceURL]; Przynajmniej, to jedyny znany mi sposób pobrania dowolnego adresu URL. –

+0

LUB możesz użyć w następujący sposób .. 'UIImage * obraz; [UIImagePNGRepresentation (image) writeToFile: @ "Twoja niestandardowa ścieżka" atomowo: TAK]; ' –

Powiązane problemy