0

我刚刚使用 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(@"....");
}
4

1 回答 1

0

我不确定,但我认为这是因为系统的内存是动态分配的,所以当它意识到它需要更多来处理按钮动作时,它会使用更多的内存

于 2013-05-24T12:41:59.337 回答