앱 자체에 이미지를 저장하고 로드하는 방법입니다.
각각의 앱에는 지정된 도큐먼트 디렉토리가 할당됩니다.
디렉토리를 얻어오고 파일명을 지정하여 저장/로드 하는 코드입니다.
경로형식 /Users/kaudo/Library/Application Support/iPhone Simulator/4.0.1/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents/
NSArray *aryPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *strPathBackground=[NSString stringWithFormat:@"%@/kaudo.jpg",[aryPath objectAtIndex:0]];
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(imgBackground,80)];
[imageData writeToFile:strPathBackground atomically:YES];
NSArray *aryPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *strPathBackground=[NSString stringWithFormat:@"%@/kaudo.jpg",[aryPath objectAtIndex:0]];
imageView.image=[[UIImage alloc] initWithContentsOfFile:strPathBackground];
댓글을 달아 주세요
안녕하세요
2012.08.08 11:20 [ ADDR : EDIT/ DEL : REPLY ]질문좀드려도될까요
혹시 이미지 저장 셋째줄 (imgBackground,80) 가 뭘 뜻하는지 알고싶습니다.
또한 카메라에서 찍은 사진을
위의 코드로 저장 후
위의 코드로 따로 사진첩에서 로드하는게 가능한지요..?
음 (imgBackground,80)은
2012.08.08 14:24 신고 [ ADDR : EDIT/ DEL ]UIImageJPEGRepresentation(이미지경로,압축비율) 입니다.
사진첩 로드는 다른 코드로 구현하셔야 할 것 같아요 ^^