있는 UITableViewCell의있는 contentView에 하나 개 이상의 항목을 추가하는 방법 상당히 복잡한있는 UITableViewCell 및 생산 코드에서 나는 다음과 같은내가있어
[[[[[[cell subviews] objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:4];
모든 작품으로 선택한 UILabel의를 꺼내 수 있어요 아무런 문제가 없습니다 - 제가 겪고있는 문제는 이것이 어떻게 작동 할 것으로 예상되는지를 보여주는 간단한 단위 테스트를 만들려고 할 때입니다. 나는 셀의있는 contentView 속성에이 개 항목이 시나리오를 구축 할 수 아니에요 어떤 이유
그래서
난 쉽게 얻을 수있는 [[셀 파단] objectAtIndex : 0]하지만 결코 1
내 테스트 도우미에서난 당신이 뷰 1와 뷰 2에 LABEL1를 추가 할 수 없습니다
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
UIView *view1 = [[UIView alloc] init];
UILabel *label1 = [[UILabel alloc] init];
UIView *view2 = [[UIView alloc] init];
UILabel *label2 = [[UILabel alloc] init];
[view1 addSubview:label1];
[cell.contentView addSubview:view1];
[view2 addSubview:label1];
[view2 addSubview:label2];
[cell.contentView addSubview:view2];
NSLog(@"inside ...%@", [[cell subviews] objectAtIndex:1]);