iPhone:尝试切换视图仅在第三个交换机上产生 EXC_BAD_ACCESS

发布于 2024-08-22 00:03:14 字数 842 浏览 4 评论 0原文

我已经实现了一个应用程序,它显示了一张带有很多图钉的地图。 如果按下一个引脚,您会看到第二个视图,显示引脚背后的数据。 按钮可带您返回地图。

我的问题是,在第三次触摸引脚时,程序会崩溃,并在此方法中显示 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相守太难 2024-08-29 00:03:14

将 NSLog 语句放在 if 的每个分支中。您几乎肯定会看到此语句会导致问题:

  [details viewDidLoad];

这是因为在某些时候您执行了此操作:

  [details release];

有效地使详细信息无法访问。顺便说一句,您几乎永远不应该直接调用 viwewDidLoad

Put NSLog statements in each branch of the ifs. You will almost assuredly see that this statement causes the problem:

  [details viewDidLoad];

This is because at some point you execute this:

  [details release];

effectively making details inaccessible. By the way you should also almost NEVER call viwewDidLoad directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文