我有另一個UITableView的問題,應用程序崩潰後重新加載tableView後從互聯網加載數據,崩潰發生在cellForRowAtIndexPath方法顯式地方。 我的thin i我仍然不完全明白究竟是什麼意思回收細胞。 感謝您的幫助EXEC_BAD_ACCESS with cellForRowAtIndexPath,再次
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UILabel *venueName;
UIImageView *logo;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSLog(@">>> GIT 1<<<");
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
venueName = [[UILabel alloc] initWithFrame:CGRectZero];
[venueName setLineBreakMode:UILineBreakModeWordWrap];
[venueName setMinimumFontSize:FONT_SIZE];
[venueName setNumberOfLines:0];
[venueName setFont:[UIFont systemFontOfSize:FONT_SIZE]];
[venueName setTag:1];
venueName.backgroundColor = [UIColor clearColor];
[[cell contentView] addSubview:venueName];
logo = [[UIImageView alloc] initWithFrame:CGRectZero];
[logo setTag:10];
[[cell contentView] addSubview:logo];
cell.backgroundView = [[[UIImageView alloc] init] autorelease];//new
}
NSMutableDictionary *oneVenue ;
if ([self.venueList count] > 0) {
oneVenue = [self.venueList objectAtIndex:indexPath.row];
if (!venueName) {
venueName = (UILabel*)[cell viewWithTag:1];
}
[venueName setText:[oneVenue objectForKey:@"Name"]]; // <===CRASH!!!
[venueName setFrame:CGRectMake(CELL_CONTENT_MARGIN,CELL_VENUE_LEVEL ,80 , 30)];
[logo setImage:[UIImage imageNamed:@"event.png"]];
[logo setFrame:CGRectMake(10, 5, 76, 60)];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImage *rowBackground;
rowBackground = [UIImage imageNamed:@"evbgd_yell.png"];
((UIImageView *)cell.backgroundView).image = rowBackground;
}
return cell;
}
p.s.有人可以告訴如何放置代碼,使其看起來像代碼? – Mapedd 2010-08-11 20:36:49
這是010101按鈕。 – mvds 2010-08-11 20:39:57