我有以下问题:
我有一个AppDelegate,我在那里添加了一个navigationController并在其中加载UIViewController B。
在B中,我添加了navigationItem、leftBarButtonItem或rightBarButtonItem。
我必须在哪里释放这些项目,因为我在B中分配和输入它们,所以在第一次我考虑释放self.navigationItem.rightBarButtonItem在Dealloc-方法的B。
但是,如果我在分析我的应用程序,分析器在B的解锁方法中的发布位置上说:
调用方此时不拥有的对象的引用计数的
不正确的递减。
但我不明白我做错了什么,或者一切都还好,这是分析器的问题?
有人能帮我查清楚吗?
问候andi1984
发布于 2011-08-31 20:14:57
一旦分配并分配给rightBarButtonItem,您就可以发布如下
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showNewEventViewController)];
self.navigationItem.rightBarButtonItem = rightBarButtonItem;
[rightBarButtonItem release];类似于leftBartButtonItem
self.navigationItem.rightBarButtonItem可能本身就有一个保留,并且知道什么时候应该释放这个值。
https://stackoverflow.com/questions/7262764
复制相似问题