我正在开发我的学校项目,我选择构建一个使用相机的应用程序。我已经设法使用它并将其附加到UIImageView
中,但是当应用程序被杀死时,我很难使该图像永久化。
我的意思是,当我杀死应用程序并再次打开它时,我希望图像保留在我附加它的视图上,因为在我当前的项目中,当我杀死应用程序时,当我再次打开应用程序时图像也消失了。
这是我的代码:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
insertPhoto1.contentMode=UIViewContentModeCenter;
[insertPhoto1 setImage:image];
[self dismissModalViewControllerAnimated:YES];
}
这对于 Tap:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];