0
我有一個按鈕來捕獲圖片,然後保存到photoAlbum。我用另一個按鈕來加載圖像使用imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
然後我實現了didFinishPickingMediaWithInfo:
加載相冊到newImage。我的需要是捕捉照片後,我有alertview,然後單擊是按鈕自動加載上次捕獲的圖像PhotoAlbum並添加newImage。可能嗎?如何從相冊加載捕獲的圖像
- (void)saveImageToPhotoAlbum
{
[self.library saveImage:[self stillImage] toAlbum:@"Album" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Gallery"
message:@"Do you want to use the captured image?" delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Yes", nil];
alertView.tag = 2;
[alertView show];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//set image
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
[newImage setFrame:CGRectMake(0, 0, 320, 568)];
[self.view addSubView:newImage];
}
我需要最後拍攝的圖像顯示於alertView按鈕的點擊newImage:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1){
}
}
未聲明varaiable拾取器的位置:[拾取器dismissViewControllerAnimated:YES完成:無]; – user3496826
它不起作用 – user3496826
在.h文件中聲明UIImagePickerController * myPicker。 –