hi guys, I've written a little programme with a couple of UIImage animations and a random string grab from a plist. Been trying to put it on the iphone but it says there are issues... so i put it through a leak programme and it said there were memory leaks.
tried releasing more things but it crashes. Any help would be fantastic.
thanks
tried releasing more things but it crashes. Any help would be fantastic.
thanks
Code:
@implementation MainViewController
@synthesize quoteLabel;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
}
return self;
[nibNameOrNil release];
}
- (void)viewDidLoad {
UIImageView* fireView = [[UIImageView alloc] initWithFrame:self.view.frame];
fireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"plainshroom.png"],
[UIImage imageNamed:@"blinkshroom"],
nil];
fireireView.animationDuration = 14.00;
// repeat the annimation forever
fireView.animationRepeatCount = 0;
// start animating
[fireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView];
[fireView release];
}
-(IBAction) shockedShroom{
UIImageView* shockedView = [[UIImageView alloc] initWithFrame:self.view.frame];
// load all the frames of our animation
shockedView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"star1.png"],
[UIImage imageNamed:@"star2.png"],
[UIImage imageNamed:@"star3.png"],
[UIImage imageNamed:@"star4.png"],
[UIImage imageNamed:@"star6.png"],
[UIImage imageNamed:@"star7.png"],
[UIImage imageNamed:@"star8.png"],
nil];
shockedView.animationDuration = 0.30;
shockedView.animationRepeatCount = 4;
// start animating
[shockedView startAnimating];
// add the animation view to the main window
[self.view addSubview:shockedView];
[shockedView release];
}
- (void)readPlist
{
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"quotes.plist"];
NSArray *array1 = [[NSArray arrayWithContentsOfFile:finalPath]retain];
srandom(time(NULL));
int r = random() %140;
NSString *arrayData1 = [array1 objectAtIndex:r];
quoteLabel.text = arrayData1;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:quoteLabel cache:YES];
UIView.animationDuration = 2.00;
[UIView commitAnimations];
quoteLabel.text = arrayData1;
[arrayData1 release];
}
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)showInfo:(id)sender {
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)dealloc {
[quoteLabel release];
[super dealloc];
}
@end