Stack Overflow 및 기타 사이트에서 수십 개의 질문/답변을 빗어 봤지만 제대로 작동하지 않습니다. 그것은 꽤 일반적인 문제처럼 보이지만, 내가 찾은 다른 질문의 답 중 어느 것도 적용되지 않았습니다. 기본적으로 테이블 셀에 간단한 UITextView를 추가하려고하는데 표시되지 않습니다. 여기에 내가 가진 것 :UITableViewCell이 하위보기를 표시하지 않습니다. UITextView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
UITextView *textviewFactoid = nil;
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"cell"];
textviewFactoid = [[UITextView alloc]initWithFrame:CGRectMake(0, -3, 300, 25)];
[textviewFactoid setFont:[UIFont systemFontOfSize:12.0f]];
[textviewFactoid setBackgroundColor:[UIColor blueColor]];
[textviewFactoid setTextColor:[UIColor grayColor]];
[textviewFactoid setScrollEnabled:NO];
[textviewFactoid setEditable:NO];
[textviewFactoid setTag:98];
[[cell contentView] addSubview:textviewFactoid];
} else {
textviewFactoid = (UITextView*)[cell.contentView viewWithTag:98];
}
NSString *textviewFactoidText = @"Here is the factoid";
[textviewFactoid setText:textviewFactoidText];
return cell;
}
왜 셀이 비어 있는지 알 수 있습니까? 나는 backgroundColor를 blue로 설정하여 textview가 전혀 존재하지 않는 것을 볼 수 있었고 그렇게 보이지 않았다. 나는 틀린 점을 정확히 찾아 낼 수 있도록 어떤 오류나 경고도받지 못하고있다.
나는이 코드를 내가 작성한 다른 응용 프로그램에서 거의 그대로 그대로 복사했으며 그곳에서 정상적으로 작동한다 ... 나는 그것이 내가 잃어버린 것 또는 변경된 것이라고 확신한다. 엉망진창.
누구보다 날카로운 눈을가집니다.
예 블록에 중단 점을 지정하십시오.이 대답에 나와있는 이유 때문에 호출되지 않을 가능성이 있습니다. – Idles
네, 이것은 커스텀'UITableViewCell' 클래스를 가진 Interface Builder에서 더 잘 수행됩니다. –
충분합니다. 이제 커스텀 Cell 클래스를 만드는 법을 배우게됩니다. 고마워요 여러분! – Nerrolken