- (void)viewDidLoad
{
[super viewDidLoad];
self.predictionsObjectArray = [[AAPredictions alloc] init];
self.animationImagesMutableArray = [NSMutableArray new];
[self.predictionsObjectArray setPredictionsArray:@[@"Probably Not", @"Ask Again", @"I doubt it", @"Unlikely", @"I believe so"]];
for (int x = 1; x<61; x++) {
NSMutableString *imageName = [[NSMutableString alloc] init];
if (x > 9) {
imageName = [NSMutableString stringWithFormat:@"CB000%i.png", x];
}
else {
imageName = [NSMutableString stringWithFormat:@"CB0000%i.png", x];
}
[self.animationImagesMutableArray addObject:[UIImage imageNamed:imageName]];
}
self.background_image.animationImages = self.animationImagesMutableArray;
self.animationImagesMutableArray = NULL;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark Prediction
-(void)makePrediction {
self.predictionLabel.text = [self.predictionsObjectArray getPrediction];
[self animateItems];
}
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
if (flag == true) {
self.image_button.alpha = 1;
}
}
-(void)animateItems {
self.image_button.alpha = 0.0;
self.background_image.animationRepeatCount = 1;
if (self.background_image.animationImages == NULL) {
self.background_image.animationImages = self.animationImagesMutableArray;
}
self.background_image.animationDuration = 3;
[self.background_image startAnimating];
[self performSelector:@selector(postAnimation) withObject:nil afterDelay:4.25];
}
-(void)postAnimation {
self.image_button.alpha = 1;
self.background_image.animationImages = NULL;
}
#pragma mark Actions
-(void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (self.background_image.isAnimating != true) {
[self makePrediction];
}
}
- (IBAction)button_pushed {
if (self.background_image.isAnimating != true) {
[self makePrediction];
}
}
@end
I am new to programming and am doing a class online and had to create a crystalBall app. I wanted to take it a step further and add a button functionality. So that button is basically the crystal ball showing up and disappearing(goes away during animation). The problem i’ve had for the last few days that i can’t get is in the debugger i have all the images stored in memory after the makePrediction function is called… it’s about 187MB. i know it’s not a lot, but the app starts with 27MB. how do i release it from memory then restore the images back into the background_image.animationImages every time that function is called?