不知道是否有人知道是否存在實際限制的UITableViewCells數量不斷被重新利用......?首先,我很清楚所有的Obj-C/Apple內存管理規則(我會首先說明,所以我不會浪費任何人的時間,也不會浪費我的)UITableViewCell AutoRelease導致崩潰...?
所以我會問這個問題out ...是否存在一些關於重用UITableViewCell的「Autorelease」機制的實際限制..?因爲我似乎只是經歷了一定數量的崩潰,所以通常超過50頁的單元格(大約50頁+ 50單元格)被翻上......然後出於否定 - 我會在這裏崩潰..有時從不發生在所有的,有時會發生相當頻繁,這取決於內容密度...
它會更好手動啓動保持和釋放我自己..? 如果是這樣,有人會有經驗推薦一個好地方釋放他們..?
[tableview tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x14e0a920
好吧....我沒能找到任何與實際的UITableViewCell(單元格內容或細胞本身),但增加後的數保留到控制器(其實例化的UITableView對象)的「撞車」神祕就不來了......
這裏是我的改變。基本上,我添加了三個Retain語句,順便說一下,我使用了自定義的「Iphone專家」中的「How To」 - 「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];
你能解釋一下多一點 - 爲什麼正是你得到一個崩潰?你有什麼樣的視圖結構(50個頁面各有50個單元 - 你有50個不同的表格視圖?)。也許發表您的cellForRowAtIndexPath方法... – Vladimir 2011-05-06 08:25:52
爲什麼你認爲你的代碼是完美的,它是一個蘋果的限制 - 發佈一些代碼:) – deanWombourne 2011-05-06 09:10:17