在我的应用程序中,我需要将 6 张图片上传到服务器。我捕获图像然后上传它,然后转到下一个并执行相同的操作。
当我到达第 5 张图像并收到 3 或 4 个内存警告后,应用程序崩溃
这是图像选择器的代码
-(void) TakePhotoWithCamera {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker1 = [[UIImagePickerController alloc] init];
picker1.sourceType = UIImagePickerControllerSourceTypeCamera;
picker1.allowsEditing = YES;
picker1.delegate = self;
[self presentViewController:picker1 animated:YES completion:nil];
}
}
这是完成捕获时的方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage * img = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[picker dismissViewControllerAnimated:YES completion:nil];
UIButton * tappedBtn = (UIButton *) [self.horizontalScrollView viewWithTag:chosenImgBtnTag];
[tappedBtn setImage:img forState:UIControlStateNormal];
[self useImage:img]; // this method upload the image to the server
info = nil;
}
这是setImage的方法
- (void) useImage:(UIImage *) image {
currentImageToUpload = image;
[self showLoadingIndicatorOnImages];
[[CarAdsManager sharedInstance] uploadImage:image WithDelegate:self];
}
所以请在这件事上有什么帮助吗?