내 UITableView
에서 마지막 셀에 로딩 표시기를 표시하려고합니다. 나머지 셀의 경우 제대로 작동하는 사용자 정의 테이블보기 셀을 만들었습니다. 하지만 끝으로 스크롤하면 크래시가 발생하고로드 인디 터 (다른 사용자 정의 셀 뷰)를로드 할 수 없습니다. 여기 내 코드가있다.iPhone - 두 가지 다른 사용자 정의 셀보기를 표시하는 UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"HomeViewCell";
UITableViewCell* cellToReturn = nil;
// Configure the cell.
NSInteger row = [indexPath row];
if (row < [jokesTableArray count])
{
CustomTableCell* cell = (CustomTableCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[CustomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSDictionary* dict = [jokesTableArray objectAtIndex:indexPath.row];
NSNumber* rating = [[ServerCommunicator getInstance] getCurrentUserJokeRating:[dict objectForKey:@"id"]];
cell.userRatedTheJoke = rating != nil ? YES : NO;
cell.titleLabel.text = [dict objectForKey:@"title"];
cell.descriptionLabel.text = [dict objectForKey:@"text"];
cell.upVotes.text = [NSString stringWithFormat:@"%2.2f",[[dict objectForKey:@"rating_count"] floatValue]];
[cell setRating:rating != nil ? [rating intValue] : [[dict objectForKey:@"rating_count"] intValue]];
NSString* authorName = [dict objectForKey:@"author"];
if (authorName != nil && ![authorName isEqual:[NSNull null]])
{
cell.author.text = [NSString stringWithFormat:@"By:%@",authorName];
}
cellToReturn = cell;
}
else
{
KMLoadingIndicatorCell* cell = (KMLoadingIndicatorCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
KMLoadingIndicatorCell* cell = [[[KMLoadingIndicatorCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.loadingLabel.text = @"Loading...";
cellToReturn = cell;
}
}
return cellToReturn;
}