【发布时间】:2011-10-06 10:55:40
【问题描述】:
我的很多内存泄漏都来自这个识别滑动的代码。我究竟做错了什么?第一行是我认为正在泄漏的东西(使用仪器)。它被显示为许多错误的负责调用者 这是在 ViewDidLoad 中:
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
[(UISwipeGestureRecognizer *)swipeRight setNumberOfTouchesRequired:2];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[webView addGestureRecognizer:swipeRight];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
[(UISwipeGestureRecognizer *)swipeLeft setNumberOfTouchesRequired:2];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
[webView addGestureRecognizer:swipeLeft];
// Do any additional setup after loading the view from its nib.
}
还有一个问题,什么会导致这里出现僵尸?我应该自动发布吗?
AViewController *a = [[AViewController alloc]init];
[self.navigationController pushViewController:a animated:YES];
a.title =@"A View";
[a release];
更新 3:我运行工具来寻找错误的分配,并且通过一些密集的使用,我在这里得到了一个僵尸:
错误信息:An Objective-C message was sent to a deallocated object (zombie) at address: 0xf583270.
在仪器中,这就是我所看到的。 Instruments 突出显示了这条线,并且旁边有 100%。
AViewController *a = [[AViewController alloc]init];
【问题讨论】:
标签: iphone ios xcode memory-management memory-leaks