UINavigationController - 相同的viewController

时间:2009-06-29 17:29:35

标签: iphone uinavigationcontroller

我有一个应用程序,我试图递归加载视图。所以我有一个视图(theViewController)能够向下钻取到同一类型的另一个视图(theViewController)。我的递归工作正常,后退按钮工作得很好。但我正在尝试实现一个有效的函数,然后卸载当前视图。

在我的代码的另一个地方,我有以下内容:

MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *navigationController = [delegate navigationController];
[navigationController popViewControllerAnimated:YES];

它也在函数的末尾为该视图(theSecondViewController)做了一些工作,但它加载了一个不同的视图(theViewController)。

我的问题是当我在我的theViewController中使用这个SAME代码时,它会崩溃。好吧,有点儿。我认为它会通过并关闭控制器,但是当它试图将视图(theViewController)重新加载到它的左侧(在它上面,但你想要考虑它)它就会死掉。一旦进入蓝色月亮,它就会吐出来:

malloc: *** error for object 0xfb9640: double free
*** set a breakpoint in malloc_error_break to debug

但通常它会在没有错误的情况下死掉(至少我认为这就是这些东西):

GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 15739.

任何帮助理解为什么它可能会在重新加载页面时死亡将非常有帮助。

更新: 如果笔尖出现错误则不会出现问题吗?我相信这是正确的。我只是不确定代码的位置[navigationController popViewControllerAnimated:YES];我以为它会转到下一个视图的viewDidLoad。但我在那里有一条NSLog消息而且没有出现。

到目前为止我能做的导航是:

userViewController -> theViewController -> ... -> theViewController -> theSecondViewController 

如果直接插入它可以正常工作。上面的代码适用于SecondViewController,但不适用于ViewController

2 个答案:

答案 0 :(得分:0)

您确定笔尖配置正确吗?我已经遇到过这种情况,结果证明是笔尖。可能是,我不记得笔尖究竟出了什么问题。有一阵子了。

但这是要检查的东西。此外,您是否试图通过代码并确定它停止工作的位置?我不确定根据上面提供的内容直接给出答案...

答案 1 :(得分:0)

我遇到的问题是我不应该发布NSManagedObjects。