Take photos or get pictures from the picture library in the process of easy to flash back, there will always be a memory pressure warning, the first step, you can first consider cutting the picture, in fact, may not need that big. Second, consider putting time-consuming such as stored procedures into threads.
This encapsulates the class method of cropping the picture.
navview.m
#define IMAGE_MAX_SIZE_WIDTH 640
#define Image_max_size_geight 1136
+ (UIImage *) Fitsmallimage: (UIImage *) image{if(Nil = =image) { returnNil; } if(Image.size.width<image_max_size_width && image.size.height<image_max_size_geight) { returnimage; } cgsize Size= [self fitsize:image.size]; Uigraphicsbeginimagecontext (size); CGRect rect= CGRectMake (0,0, Size.width, size.height); [Image Drawinrect:rect]; UIImage*newing =Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); returnnewing;}+ (cgsize) Fitsize: (cgsize) thissize { if(Thissize.width = =0&& Thissize.height = =0) returnCgsizemake (0,0); CGFloat Wscale= thissize.width/Image_max_size_width; CGFloat Hscale= thissize.height/Image_max_size_geight; CGFloat Scale= (Wscale>hscale)?Wscale:hscale; Cgsize newSize= Cgsizemake (Thissize.width/scale, thissize.height/Scale ); returnNewSize;}
Using eg:
Set the image to be manipulated as image(uiimage)
Image=[navviewFitsmallimage:Image];