내 컨트롤러이 있습니다 [postCell setPost:post];
와있는 UITableViewCell 사용자 정의 서브 뷰는
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PostCell";
PostCell *postCell = (PostCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
Post *post = self.displayPosts[indexPath.row];
[postCell setPost:post];
return postCell;
}
나는 그 사용하려는 내 사용자 정의 셀 모델을 보낼 수 있습니다.
- (void)setPost:(Post *)newPost
{
if (_post != newPost) {
_post = newPost;
}
[self setNeedsDisplay];
}
이제이 버전을 사용하고 있지만 변경하고 싶습니다. 지금 나는 을 가지고 있는데, drawRect
을 호출합니다. - subviews
을 어떻게 사용하고 싶습니까? 그 _POST에 따라 내가 파단 값을 설정 할 IBOutlets
(imageviews
이미지, labels
텍스트 등 ...) 사용하는 경우
어디서 subviews
를 추가합니까?
또는 drawRect를 사용하여 buttons
을 내 셀에 추가하는 방법과 이미지 및 버튼 drawRect
에서 touch
을 감지하는 방법을 가르쳐 주시겠습니까? 그렇게하면 현재 버전을 바꿀 필요가 없습니다.
'setPost' 함수에서 뷰를 생성하고 (셀 필요에 따라) 뷰를 셀의 서브 뷰로 추가해야합니다 :'[self.contentView addSubview : newView]'. 그런 다음 셀에 포함시키려는 다른보기에 대해 다시 수행하십시오. – Putz1103