我有一個非常簡單的UITableView,它有3個部分,每部分3行。滾動時基本UITableView的內存問題
#pragma mark -
#pragma mark UITableView delegate methods
- (NSInteger)tableView:(UITableView *)tblView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tblView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tblView
{
if (tblView == self.tableView) {
return 3;
}
else {
return 1;
}
}
樣樣精顯示出來,但只要我滾動我的應用程序崩潰,我的調試器告訴我:
***** - [ProfileViewController的tableView:的cellForRowAtIndexPath:]:消息發送到釋放實例0x5ae61b0 **
我不完全確定我做錯了什麼。
編輯: 這是怎麼了顯示ProfileViewController:
ProfileViewController* profileView = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
profileView.user_name = username;
profileView.message_source = messageSource;
[self.navigationController pushViewController:profileView animated:YES];
[profileView release];
我已更新我的代碼以顯示如何顯示我的ProfileViewController。你看到有什麼不對嗎? – 2010-05-24 18:02:27
我改變了我的NIB包含一個ViewController和一個TableView而不是TableViewController。它似乎在伎倆。不知道爲什麼。 – 2010-05-24 18:20:14