我有一个非常简单的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