[英]Custom UITableViewCell On Autorelease causes a crash in application
[英]UITableViewCell AutoRelease causing crash…?
不知道是否有人知道不断重复使用的UITableViewCells数量是否存在实际限制...? 首先,我非常了解所有Obj-C / Apple内存管理规则,(我将首先说明这一点,所以我不会浪费任何人的时间,他们也不会浪费我的时间)
因此,我会直截了当地问这个问题……关于重用UITableViewCell的“自动释放”机制是否存在一些实际限制? 因为我似乎只是在经过一定次数后才经历崩溃,所以通常翻过来价值超过50页的单元格(大约50页+ 50个单元格)……然后无处不在,我会遇到此崩溃。有时完全发生,有时非常频繁,具体取决于内容的密度...
最好自行开始手动保留和释放..? 如果是这样,那么有人会推荐一个释放他们的好地方吗?
[tableview tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x14e0a920
好的...。我找不到与实际的UITableViewCell(单元格内容或单元格本身)有关的任何内容,但是在向控制器添加了一些保留(实例化UITableView对象)后,“崩溃”神秘地停止了显示...
这就是我所做的更改。 基本上,我添加了三个Retain语句,顺便说一句,我使用了自称“ Iphone Expert”的“ How To”-“ UITabBarController”上的原始示例教程,但“ Expert”否定了保留项。 (这只是代码的适用部分...)
//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];
AFAIK仅受设备上可用内存的限制-我假设它在自动释放池和表视图的可重用单元格中使用了某种动态集(即NSSet或更低级别的等效项)。
我使用了具有成千上万行的表视图,没有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.