iphone - UITableViewCell AutoRelease 导致崩溃...?

标签 iphone cocoa-touch ios uitableview autorelease

不确定是否有人知道不断重用的 UITableViewCell 数量是否存在实际限制......?首先,我非常了解所有 Obj-C/Apple 内存管理规则,(我将首先声明这一点,这样我不会浪费任何人的时间,他们也不会浪费我的时间)

所以我会直接问这个...关于重用 UITableViewCell 所附加的“自动释放”机制是否有一些实际限制...?因为我似乎只在一定数量后才遇到崩溃,通常超过 50 页的单元格(大约 50 页 + 50 个单元格)被翻转......然后不知从何而来我会遇到这个崩溃......有时永远不会会发生,有时会发生得很频繁,具体取决于内容密度......

我自己开始手动保留和释放会更好吗? 如果是的话,有人有经验可以推荐一个放生的好地方吗?

[tableview tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x14e0a920

好吧....我找不到与实际 UITableViewCell (单元格内容或单元格本身)有关的任何内容,但是在向 Controller (实例化 UITableView 对象)添加一些保留后,“崩溃”神秘地停止出现...

这是我改变的。基本上我添加了三个 Retain 语句,顺便说一句,我使用了自称“Iphone 专家”的“​​如何”-“UITabBarController”的原始示例教程,但“专家”否定了包含保留...... (这只是代码的适用部分...)

//initialize the UITabBarController
tabBarController = [[UITabBarController alloc] init];
TabBarControllerSet = TRUE;

//Create the first UITabBarItem
MainMessageBoard *mainMessageBoard = [[MainMessageBoard alloc] initWithController: self];
[mainMessageBoard setTitle:@"?????"];
[mainMessageBoard retain];    ////******** ADDED This RETAIN ***********

//Create the second UITabBarItem
PostNewComment *postNewComment = [[PostNewComment alloc] initWithController: self];
[postNewComment setTitle:@"????"];
[postNewComment retain];  ////******** ADDED This RETAIN ***********

//Create the third UITabBarItem
logout *Logout = [[logout alloc] initWithController: self];
[Logout setTitle:@"?????"];
[Logout retain];   ////******** ADDED This RETAIN ***********


//add the UIViewControllers to the UITabController
tabBarController.viewControllers = [NSArray arrayWithObjects:mainMessageBoard, postNewComment, Logout, nil];
[tabBarController setDelegate:self];

//release
[mainMessageBoard release];
[postNewComment release];
[Logout release];

[self.view addSubview:tabBarController.view];

最佳答案

据我所知,它仅受设备上可用内存的限制 - 我假设它在自动释放池和 TableView 的可重用单元格中使用某种动态集(即 NSSet 或较低级别的等效项)。

我已经使用了包含数万行的 TableView ,没有任何问题。

关于iphone - UITableViewCell AutoRelease 导致崩溃...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5908690/

相关文章:

iphone - 适用于 ios 3.0 和更新版本的 UIWebView 的捏缩放

ios - FetchedResultsController 和 GDC 之间对于从网络下载到表格 View 中的图像的冲突?

ios - 为什么 pod install 会改变原来的 Podfile 和 xcode 工作区?

iphone - iPhone 上 NSSetUncaughtExceptionHandler 的替代品

ios - 无法添加文件 iOS 应用程序包

iphone - 使用 NSPredicate iOS 在具有 NSArray 和 NSString 的 NSArray 中查找值

objective-c - 使用 RESTKit 做一个简单的 json POST

ios - CocoaPods 没有将 Firebase SDK 更新到版本 4.0.0

iphone - 将具有 "Assign"属性的对象设置为 nil

ios - 从 iPhone 上的弹出 View Controller 传回数据