IOS 儲存圖片至相簿
1 |
void UIImageWriteToSavedPhotosAlbum
( |
2 |
UIImage
*image, |
3 |
id
completionTarget, |
4 |
SEL
completionSelector, |
5 |
void *contextInfo |
6 |
); |
image
帶儲存的圖片UImage物件
completionTarget
影象儲存至相簿後呼叫completionTarget指定的selector(可選)
completionSelector
completionTarget的方法對應的選擇器,相當於回撥方法,需滿足以下格式
1 |
-
( void )
image: (UIImage *) image |
2 |
didFinishSavingWithError:
(NSError *) error |
3 |
contextInfo:
( void *)
contextInfo; |
當我們需要非同步獲得影象儲存結果的訊息時,我們需要指定completionTarget物件以及其completionSelector對應的選擇器。示例如下:
01 |
-
( void )saveImageToPhotos:(UIImage*)savedImage |
02 |
{ |
03 |
UIImageWriteToSavedPhotosAlbum(image,
self, @selector(image:didFinishSavingWithError:contextInfo:), NULL); |
04 |
} |