My app crashes after multiple rotates
- by Ian Rae
My app is crashing when I try and rotate it more than a couple of times. I first thought it was just the iPhone Simulator, so I loaded the app onto an iPod touch, and it crashed after fewer rotates in a row. I suspect it's a memory leak in one of my rotate methods. The only place I can think that the crash is being caused is in willRotateToInterfaceOrientation:duration:. The only two methods related to rotate that I've added/extended are shouldAutorotateToInterfaceOrientation: and willRotateToInterfaceOrientation:duration and I don't think it's the first because it only contains the two words: return YES;. Here is my willRotateToInterfaceOrientation:duration: method so you can review it and see where the possible memory leak is.
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
UIFont *theFont;
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
{
theFont = [yearByYear.font fontWithSize:16.0];
yearByYear.font = theFont;
[theview setContentSize:CGSizeMake(460.0f, 635.0f)];
}
else
{
theFont = [yearByYear.font fontWithSize:10.0];
yearByYear.font = theFont;
[theview setContentSize:CGSizeMake(300.0f, 460.0f)];
}
[theFont release];
}
yearByYear is a UITextView
theview is a UIScrollView
if anyone has any idea of why my app is crashing, I would be greatly appreciative.