这是我的代码:标题:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
UIImageView *imageView;
NSMutableArray *arrayWithImages;
}
- (IBAction)startAnimation:(id)sender;
- (IBAction)cleanMemory:(id)sender;
@end
执行:
#import "ViewController.h"
@implementation ViewController
......
- (IBAction)startAnimation:(id)sender {
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
arrayWithImages = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"pic1"],
[UIImage imageNamed:@"pic2"],
[UIImage imageNamed:@"pic3"],
[UIImage imageNamed:@"pic4"],
[UIImage imageNamed:@"pic5"],
[UIImage imageNamed:@"pic6"],
[UIImage imageNamed:@"pic7"],
[UIImage imageNamed:@"pic8"],nil];
imageView.animationImages = arrayWithImages;
imageView.animationDuration = 3;
imageView.animationRepeatCount = 1;
[self.view addSubview:imageView];
[imageView startAnimating];
}
- (IBAction)cleanMemory:(id)sender {
[arrayWithImages removeAllObjects];
[arrayWithImages release];
arrayWithImages= nil;
[imageView removeFromSuperview];
[imageView release];
imageView = nil;
}
@end
我有ViewController
,它view
有两个按钮。第一个带有动作的按钮,startAnimation
它创建并在其上启动动画。第二个带有动作的按钮,它清除了我在其中创建的所有内容。当我从仪器开始时,我的程序有,当我按下按钮时它会变成动画,然后我按下 按钮,但它有相同的......为什么?我不会将我的内存清理为起始值(4 mb Real Mem)。请问,你能解释一下,我哪里有问题吗?UIImageView
NSMutableArray
cleanMemory
startAnimation
Profile
Activity Monitor
4 mb Real Mem
startAnimation
16 mb Real Mem
cleanMemory
16 mb Real Mem