336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요. 개발자 myoung 입니다. 

오늘은 저장하고 싶은 이미지를 사진 앱에 노출이 될수 있도록 저장하는 방법에 대해서 알아보겠습니다.

다른 특별한 옵션을 주지 않고 단순하게 사진을 저장할때 사용 할수있는 방법입니다.

생각보다 너무 간단하고 한줄로 끝납니다.


(Obejctive-C)

1
2
3
4
5
6
7
8
9
10
11
//필요한 부분에서 호출
UIImageWriteToSavedPhotosAlbum(your_image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    if (error) {
        NSLog(@"error: %@", [error localizedDescription]);
    } else {
        NSLog(@"saved");
    }
}
cs


(Swift)

1
2
3
4
5
6
7
8
9
10
11
12
//필요한 부분에서 호출
UIImageWriteToSavedPhotosAlbum(img, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
 
func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) { 
       //사진 저장 한후
       if let error = error {
           // we got back an error!
           Toast(message: error.localizedDescription).show()  
       } else {
            // save    
       }
}
cs


궁금한점이나 틀린점이 있으면 언제든지 댓글을 달아 주세요. :)



'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)텍스트 위치 가져오기  (0) 2016.10.10
iOS)무음에서 소리 나오게 하기  (0) 2016.07.19
iOS)디바이스 정보 가져오기  (0) 2016.06.08
iOS)딕셔너리 키값 정렬 하기  (0) 2016.06.06
iOS)랜덤 함수  (0) 2016.05.26

+ Recent posts