이것은 간단한 것처럼 보이지만 나는 고생하고 있습니다.cell.textLabel.text의 텍스트에 액세스
내 스토리 보드에는 정적 셀을 사용하여 레이블이있는 텍스트가있는 셀이 있습니다. didSelectRowAtIndexPath에서 셀의 textLabel 텍스트에 액세스하려고합니다. 여기 내 코드는 NSLogging로,이다 :
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.textLabel.text) {
NSLog(@"cell.textLabel.text = %@",cell.textLabel.text);
} else {
NSLog(@"!cell.textLabel.text");
}
NSLog(@"just for fun: cell.textLabel.text = %@", cell.textLabel.text);
문은 항상 "cell.textLabel.text!"를 반환하고 스토리 보드의 세포가 텍스트를 가지고 있지만 마지막 NSLog는 항상 (NULL) 인 경우.
cell.textLabel이 올바르지 않습니까? UITableViewCell의 또 다른 하위 뷰를보고 있어야합니까?
셀 텍스트가 detailTextLabel이 아닌 textLabel에 있는지 확인하십시오. –
방금 detailTextLabel을 시도하고 똑같은 결과를 얻었습니다. –
if 문을 사용하지 않으면 어떻게됩니까? 제대로 기록됩니까? –