IPhone: Image View picture size limit

iphoneuiimageview

Hey guys first I got a picture into a image view that was 2900×2100 and the file size was about 4MB I also had an scroll view to move around the image.
Anyways it crashed, first I though it was because the 4MB size. Then I resized it making it 1287×1234 and 1.3MB but it was pixelated when I zoom it too much.
After that I manage to make it 2900×2100 with 1.5 MB! so I ran it on my device and it still crashes!!

Anybody knows why's that?
This is what I get on the debugger console

Program received signal: “0”.

warning: check_safe_call: could not restore current frame

here's more info, this is my viewDidLoad method:

UIImageView *tempimage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sanlucasFLAT.jpg"]];

self._FLatLucasImageView = tempimage;

[tempimage release];

_FLatLucasImageView.frame = CGRectMake(-7, 0, 800, 800);

_FLatLucasImageView.contentMode = UIViewContentModeScaleAspectFit;

_FlatLucasScrollView.contentSize = CGSizeMake(_FLatLucasImageView.frame.size.width,_FLatLucasImageView.frame.size.height);

_FlatLucasScrollView.delegate = self;

_FlatLucasScrollView.clipsToBounds = YES;

[_FlatLucasScrollView addSubview:_FLatLucasImageView];

[_FLatLucasImageView release];

When I set the CGRectMake to: (0,0,2900,2961) it doesn't crash when I scroll the image

Best Regards

Carlos Vargas

Best Answer

The reason why your app crashed is because the picture you are using is too big.
According to the class reference for UIImage, it says that You should avoid creating UIImage objects that are greater than 1024 x 1024 in size.

If you add a UIImage object which has a bigger image than 1024 x 1024 to a UIImageView object, your app could crash. If you are lucky, sometimes your app doesn't crash though.

Related Topic