Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jeremyapp

macrumors newbie
Original poster
Apr 30, 2008
27
0
Hey,

I'm making an eBook app that presents a table view for a user to pick a book, and then based on that selection, loads 35 20kb jpg files into a UIScrollView. I seem to be having memory issues (from what I can tell) when the user selects a book. Sometimes it does load a book (although very slowly) and sometimes the app crashes and throws a strange error:

Code:
Program received signal:  “0”.
warning: check_safe_call: could not restore current frame

Here's what the code that lays out my book looks like:

Code:
- (void)layoutBook {
	CGRect workingFrame;
	
	workingFrame.origin.x = 0;
	workingFrame.origin.y = 0;
	workingFrame.size.height = 480;
	workingFrame.size.width = 320;
	
	int x;
	for(x=1; x<=35; x++) {
		UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@%d",currentBook,x] ofType:@"jpg"]];
		imageView = [[[UIImageView alloc] initWithFrame:workingFrame] autorelease];
		imageView.image = image;
		[scrollView addSubview:imageView];
		workingFrame.origin.x = workingFrame.origin.x + 320;
		
	}
	
	workingFrame.size.width = workingFrame.origin.x;
	[scrollView setContentSize:workingFrame.size];
	
	workingFrame.origin.x = 0;
	workingFrame.origin.y = 0;
	workingFrame.size.width = 320;
	workingFrame.size.height = 480;
	
	[scrollView setFrame:workingFrame];
}

Does anything look wrong here? Thanks!
 
Still haven't figured out a good solution yet. My guess is the phone isn't happy loading 35 UIImages. Has anyone come up with a good way to lazy-load images into a UIScrollView? I haven't found much through google or the developer forums yet.
 
Perfect - Apologies for once again underestimating (and overlooking) the sample projects.

Good find!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.