我有一个显示UIImagePicker的模态,允许用户拍摄照片然后放入UIImageView。
每隔一段时间我就会得到一个内存警告'收到内存警告'并且UIImageView没有被分配。该应用程序相当简单,并没有使用大量内存,而且似乎很多时候这与ImagePicker作为一个单独的进程有关。这仅在使用相机时发生,并且大约发生五次。
有一个lot of talk about this online,大多数答案都说'适当地处理警告';但我不确定这意味着什么 - 我只是希望拍摄的照片出现在ImageView中!似乎在我可以在UIImagePicker委托中做任何事情之前发生。
我可以做些什么来缓解这种情况?
这是didFinishPickingImage委托:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo {
//set background for image select button, put image reference somewhere to copy image to documents folder and insert into modular's sentence object.
//ImagePicker.jpg needs it's border set to 1px black.
NSLog(@"imagePickerController: selectedimage: %@", selectedImage);
imageViewBehindPhotoBigButton.clipsToBounds = YES;
[imageViewBehindPhotoBigButton.layer setBorderColor: [[UIColor blackColor] CGColor]];
[imageViewBehindPhotoBigButton.layer setBorderWidth: 1.0];
[imageViewBehindPhotoBigButton setBackgroundColor:[UIColor whiteColor]];
[imageViewBehindPhotoBigButton setContentMode: UIViewContentModeScaleAspectFill];
imageViewBehindPhotoBigButton.image = selectedImage;
imageViewBehindPhotoBigButton.hidden = NO;
[choosePhotoBigButton setBackgroundImage:nil forState:UIControlStateNormal];
choosePhotoBarImage.hidden = NO;
choosePhotoText.hidden = NO;
addButton.enabled = YES;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//because iPad uses a pop up - we don't want to dismiss modals here!
[imagePopupController dismissPopoverAnimated:YES];
}else{
[self dismissModalViewControllerAnimated:YES];
}
}