NIB에서 UITableViewCell
사용자 정의 UITableView
을 생성했습니다. 보기 컨트롤러를로드 할 때 모든 것이 제대로 작동하는 것 같습니다. 그러나 내가 UITableView
을 스크롤하기 시작하면 아무 이유없이 중간에 빈 셀이 나타나는 경우가 있습니다.사용자 정의 UITableViewCell 레이아웃 문제
나는 무슨 일이 일어나고 있는지 모른다. 내 cellForRowAtIndexPath
은 아주 간단합니다. 하지만 사용자 정의 UITableViewCell
에 제스처를 추가했습니다. 그것이 문제의 원인이 될 수 있습니까? 내 코드 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *tableIdentifier = @"FTStreamCell";
FTStreamCell *cell = (FTStreamCell *)[tableView dequeueReusableCellWithIdentifier:tableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FTStreamCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.delegate = self;
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
FTStreamCell *streamCell = (FTStreamCell*) cell;
if (!indexPath.section == 0)
{
if ((NSNull*)[[[self.cachedData objectForKey:kQuestions] objectAtIndex:indexPath.row] objectForKey:kQuestion] != [NSNull null])
streamCell.question.text = [[[self.cachedData objectForKey:kQuestions] objectAtIndex:indexPath.row] objectForKey:kQuestion];
streamCell.timePosted.text = [NSString stringWithFormat:@"Today at Bangalore, India"];
// To Show My Questions
NSLog(@"Me %d", [[[NSUserDefaults standardUserDefaults] objectForKey:kUserId] integerValue]);
if ([[[self.cachedData objectForKey:kQuestions] objectAtIndex:indexPath.row] objectForKey:kUserId] == [[NSUserDefaults standardUserDefaults] objectForKey:kUserId])
{
streamCell.mainView.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:240.0f/255.0f blue:247.0f/255.0f alpha:1];
streamCell.userCheck = YES;
}
else
{
streamCell.mainView.backgroundColor = [UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1];
streamCell.userCheck = NO;
}
[cell layoutSubviews];
}
}
감사합니다.
Xcode에서 NSZombie를 사용하면 어디에서 충돌이 발생하는지 알 수 있습니다. http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-code – freelancer
충돌이 발생하지 않습니다. 그러나 빈 칸은 여전히 존재합니다. 스크린 샷을 게시 할만큼 충분한 평판을 얻지 못했습니다. 여기에 대한 링크가 있습니다. http://i.stack.imgur.com/AgWfw.png –
빈 셀이로드되는시기를 확인하기 위해 중단 점을로 설정하십시오. 'else' 섹션에서 흰색을 사용하고 있기 때문에 비어 있습니까? – iphondroid