Bear with me as I am new to obj-c but I have a UIScrollView and a segmented button that switches between 2 images that are presented in the scrollview. Each image is large and roughly 500Kb, but they are each causing allocations of 20+ MB and crashing my app.
- (void)viewDidLoad {
[bvpiscrollview setContentSize:CGSizeMake(768, 2484)];
UIImage *loadBvImage = [UIImage imageNamed:@"bpi_1536x4965v2.png"];
bvpiimg.image = loadBvImage;
[loadBvImage release];
[super viewDidLoad];
}
-(UIView *)viewForZoomingInScrollView:bvpiscrollview{
return bvpiimg;
}
-(IBAction)pidonebutton{
[self.view removeFromSuperview];
}
-(IBAction)segmentedControlIndexChanged{
switch (self.segmentedControl.selectedSegmentIndex)
{
case 0:
[bvpiscrollview setContentSize:CGSizeMake(768, 2484)];
UIImage *loadBvImage = [UIImage imageNamed:@"bpi_1536x4965v2.png"];
bvpiimg.image = loadBvImage;
[loadBvImage release];
break;
case 1:
[bvpiscrollview setContentSize:CGSizeMake(768, 2556)];
UIImage *loadMpImage = [UIImage imageNamed:@"mpi_1536x5110v2.png"];
bvpiimg.image = loadMpImage;
[loadMpImage release];
default:
break;
}
}
- (void)dealloc {
[bvpiimg release];
[bvpiscrollview release];
[segmentedControl release];
[super dealloc];
}
@end