由于内存问题,我的应用程序在拍照时崩溃。
现在我尝试用仪器分析我的内存,实际上当应用程序崩溃时我最多使用 23 MB。我将它与那个 Facebook 应用程序进行了比较,它使用了超过 70 MB,所以我不知道为什么我会收到内存警告......
我使用以下代码:
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraOverlayView = overlay;
[self presentViewController:picker animated:NO completion:nil];
注意:我在没有覆盖视图的情况下尝试过它,它似乎没有改变 ,我尝试了有和没有动画。
顺便说一句,应用程序在显示图像选择器时不会崩溃,但是当显示图像选择器时,我会收到多个内存警告。该应用程序在拍照或点击“使用”按钮时崩溃。有时应用程序根本不会崩溃,所以我很困惑。
也许我需要在 didReceiveMemoryWarning 方法中做一些事情,但我不知道是什么,也许你可以帮助我!
Xcode 显示了这一点:
更新:
这就是我从
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImagePickerControllerMediaMetadata = {
DPIHeight = 72;
DPIWidth = 72;
Orientation = 6;
"{Exif}" = {
ApertureValue = "2.526068811667588";
BrightnessValue = "3.440519128732857";
ColorSpace = 1;
DateTimeDigitized = "2013:09:26 14:33:48";
DateTimeOriginal = "2013:09:26 14:33:48";
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.03333333333333333";
FNumber = "2.4";
Flash = 24;
FocalLenIn35mmFilm = 35;
FocalLength = "4.28";
ISOSpeedRatings = (
50
);
LensMake = Apple;
LensModel = "iPhone 4S back camera 4.28mm f/2.4";
LensSpecification = (
"4.28",
"4.28",
"2.4",
"2.4"
);
MeteringMode = 5;
PixelXDimension = 3264;
PixelYDimension = 2448;
SceneType = 1;
SensingMethod = 2;
ShutterSpeedValue = "4.906905022631062";
SubjectArea = (
1631,
1223,
881,
881
);
SubsecTimeDigitized = 551;
SubsecTimeOriginal = 551;
WhiteBalance = 0;
};
"{MakerApple}" = {
1 = 0;
3 = {
epoch = 0;
flags = 1;
timescale = 1000000000;
value = 779858689639583;
};
4 = 0;
5 = 128;
6 = 138;
7 = 0;
};
"{TIFF}" = {
DateTime = "2013:09:26 14:33:48";
Make = Apple;
Model = "iPhone 4S";
Software = "7.0";
XResolution = 72;
YResolution = 72;
};
};
UIImagePickerControllerMediaType = "public.image";
UIImagePickerControllerOriginalImage = "<UIImage: 0x15668c60>";
}