barView 저는 테이블 뷰를 가지고 있으며 각 셀에 통계 막대를 그립니다. 내 사용자 지정 셀에 빈 UIView
이 만들어지면 해당 이름은 mainView
이며 차트가 그려지는보기입니다. cellForRowAtIndexPath
에서UIView addSubview 또는 UITableViewCell에서 작업하지 않습니다.
나는이 일을 해요 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
CGRect barRect = CGRectMake(0, 0, 100, 10);
UIView *barView = [[UIView alloc] initWithFrame:barRect];
[barView setBackgroundColor:[UIColor redColor]];
[cell.mainView addSubview:barView];
return cell;
}
가 barView
로드에 표시되지 않습니다. 셀이 화면 밖으로 나간 후에 다른 탭 또는 에서 변경하고 돌아온 후에 만 표시됩니다..
참고 : 나는
[cell.mainView setNeedsDisplay];
을 시도
- 나는 다른 사용자 정의 세포로 만든 헤더를 가지고있다.
UITableViewCell에서 mainView를 추가하는 방법은 무엇입니까? – CRDave
CustomCell이라는 사용자 정의 클래스를 작성하고 mainView라는 IBOutlet 특성을 추가했습니다. 그런 다음 클래스를 셀에 할당하고 IBOutlet을 interfaceBuilder의 뷰에 할당했습니다. – Octan
'initView '란 무엇입니까? 대신에'barView'를 사용 했습니까? 그렇지 않으면 빈보기 만 만들었 기 때문에 아무 것도 볼 수 없다는 것이 분명합니다. – SAE