문제점은 다음과 같습니다. cellForRowAtIndexPath
에 가변 배열을 지정하여 각 배열 객체를 셀에 표시합니다. 지금까지 그렇게 좋았던 셀은 예상대로 표시됩니다. 이제 나는 (조건에 따라) UILabel
첫 번째 셀에 다른 가변 배열 객체가 두 번째 셀로 옮겨 지길 원합니다. 문제는 그 조건을 테스트 할 때, 사실, UILabel
은 첫 번째 셀 에 첫 번째 개체이 표시됩니다. 그래서 사실, 두 요소가 같은 셀에 있습니다. 이것은 내가 기대하는 것이 아닙니다. 나는 (조건이 true 일 때) 모든 요소를 이동하여 첫 번째 셀을 UIlabel
으로두기 위해 두 번째 셀에서 표시되도록하려고합니다. 내 논리cellForRowAtIndexPath 데이터 소스와 관련된 문제
- (UITableViewCell*)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:@"any-cell"];
// Add and display the Cell
cell.tag = [indexPath row];
NSLog(@"cell.tag= %i",cell.tag);
//test the condition, if it's ok, then add the label to the first cell
if ([self isNoScoreLabelDisplayed] && cell.tag==0) {
UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 220, 50)];
[lbl setBackgroundColor:[UIColor greenColor]];
[cell addSubview:lbl];
}
cell.tag = [self isNoScoreLabelDisplayed]?[indexPath row]+1:[indexPath row];//here i wanted to shift the tags in case the condition is true, so that all the elements will be displayed from the second cell. But seems not doing what i want :(
//
if (indexPath.row < cellList.count) {
[cell addSubview:[cellList objectAtIndex:[indexPath row]]];//cellList is the mutable array from which i get all the elements to display in the cells
}else{
[cell addSubview:nextButton];
}
return cell;
}
내가 실종 무엇인가 : 내가 무엇을 기대 저를 포기하지 않습니다
내 관련 코드이 무엇입니까? 고맙습니다.
까지 제가 헤더와 비슷한 것을 알고 싶습니다. 왜이 헤더 테이블을 사용하지 않을까요? – Pfitz
안녕하세요, 귀하의 회신에 감사드립니다. 실제로 머리글은 다른 것을하고 있습니다. 내 게임의 이름을 표시하고 있습니다. 헤더를 사용할 방법이 없습니다.) – Malloc
'셀이 생성되는 곳은 어디입니까? 해당 코드를 확장 할 수 있습니까? –