我正在開發我的學校項目,我選擇了構建使用相機的應用程序。我已經設法使用它並將其附加到UIImageView
中,但是當應用程序被殺時,我很難使圖像永久存在。Objective-C:當應用程序被殺時保存圖像
我的意思是,我希望圖像保留在視圖中,當我殺死應用程序並再次打開它時,因爲在我當前的項目中,當我殺死應用程序時,圖像也消失了,當我打開應用程序再次。
這裏是我的代碼:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
insertPhoto1.contentMode=UIViewContentModeCenter;
[insertPhoto1 setImage:image];
[self dismissModalViewControllerAnimated:YES];
}
這對於分流:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];
首先嚐試檢查碰撞發生的位置。 – sairam