我正在將相機中的圖像保存在NSMutableArray中。當我添加一張圖片時,圖片被添加到數組中。但問題是,當我拍攝另一張照片時,第一張照片被第二張照片取代。我想保存相機拍攝的所有照片。NSMutableArray中的多個圖像
- (IBAction)takePhoto {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *cameraImage = info[UIImagePickerControllerEditedImage];
self.tempView.image = cameraImage;
camImages = [NSMutableArray arrayWithCapacity:10];
[camImages addObject:self.tempView.image];
//self.chosenImages=camImages;
NSLog(@"the image is=%@",camImages);
[picker dismissViewControllerAnimated:YES completion:NULL];
}
不要每次添加內容時重新創建數組。這有點失去了舊內容。 –