我刚刚使用 xcode 创建了一个“单视图应用程序”,并在“viewDidLoad”方法中添加了一个 UITapGestureRecognizer。然后我用仪器监控内存分配,每次我点击分配的内存增加的大小。如果尝试点击几次内存使用量会增加。为什么会有这种行为?
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.view addGestureRecognizer:tapGesture];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)handleTap:(UIGestureRecognizer *) sender
{
// NSLog(@"....");
}