iPhone:尝试切换视图仅在第三个交换机上产生 EXC_BAD_ACCESS
我已经实现了一个应用程序,它显示了一张带有很多图钉的地图。 如果按下一个引脚,您会看到第二个视图,显示引脚背后的数据。 按钮可带您返回地图。
我的问题是,在第三次触摸引脚时,程序会崩溃,并在此方法中显示 EXC_BAD_ACCESS
:
- (void) switchViews {
if(self.details == nil){
Kundendetails *detailAnsicht = [[Kundendetails alloc] initWithNibName:@"ViewList" bundle:nil];
detailAnsicht.rootViewController = self;
self.details = detailAnsicht;
detailAnsicht.map = self.map;
}
if(self.details.view.superview == nil) {
[map.view removeFromSuperview];
[self.view addSubview:details.view];
[details viewDidLoad];
} else {
[details.view removeFromSuperview];
[details release];
[self.view addSubview:map.view];
}
}
How do I找出导致崩溃的代码行?为什么它总是在第三次触摸时崩溃?
我希望你能帮助我。
I have implemented an app that shows a map with a lot of pins on it.
If you push one pin you get on a second view that shows the data behind the pin.
A button takes you back to the map.
My problem is that by the third touch on a pin the program crashes with a EXC_BAD_ACCESS
in this method:
- (void) switchViews {
if(self.details == nil){
Kundendetails *detailAnsicht = [[Kundendetails alloc] initWithNibName:@"ViewList" bundle:nil];
detailAnsicht.rootViewController = self;
self.details = detailAnsicht;
detailAnsicht.map = self.map;
}
if(self.details.view.superview == nil) {
[map.view removeFromSuperview];
[self.view addSubview:details.view];
[details viewDidLoad];
} else {
[details.view removeFromSuperview];
[details release];
[self.view addSubview:map.view];
}
}
How do I isolate which line of code causes the crash? Why would it always crash only on the third touch?
I hope you could help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 NSLog 语句放在 if 的每个分支中。您几乎肯定会看到此语句会导致问题:
这是因为在某些时候您执行了此操作:
有效地使详细信息无法访问。顺便说一句,您几乎永远不应该直接调用
viwewDidLoad
。Put NSLog statements in each branch of the ifs. You will almost assuredly see that this statement causes the problem:
This is because at some point you execute this:
effectively making details inaccessible. By the way you should also almost NEVER call
viwewDidLoad
directly.