2011-07-02 5 views
0

커스텀 UITableViewCell 클래스를 사용하여 테이블 뷰 셀을 만들고 있습니다. 동적으로 행 높이를 변경하려고합니다.커스텀 UITableViewCell의 프레임 크기를 편집하는 방법?

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return 60; 
} 

행 높이에 대한 작업이 완벽합니다.

그러나 셀의 프레임 높이가 아니라 행 높이 만 변경됩니다. 셀 프레임 높이는 여전히 44입니다 (기본값). 그렇다면 행 높이뿐만 아니라 셀 프레임에도 효과적 일 수 있습니까? 미리

감사 ..

+0

Patidar : ** 셀 프레임 높이가 60이 아닌지 ** 어떻게 알 수 있습니까 **? – Jhaliya

+0

중단 점을 사용하여 응용 프로그램을 디버깅했습니다. tableViewCell 클래스에서 self.frame.size.height를 사용하여 셀 높이를 가져 왔습니다. –

답변

0

cellforrow

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 

if (cell == nil) 
{ 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,90,90) reuseIdentifier:@"MyIdentifier"] autorelease]; 
} 
return cell; 

}

음이 광고

 cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,90,90) reuseIdentifier:@"MyIdentifier"] autorelease]; 

CGRectMake 셀을 만드는 동안 (0,0,90,90) 필요에 따라 변경하십시오

+0

안녕하세요, 귀하의 회신에 감사드립니다. 그러나 이것은 나의 경우에는 충분하지 않습니다. init 메소드에서 정적 셀 프레임을 전달하는 것처럼 보입니다. 행 높이와 같아야하는 동적 셀 높이가 필요합니다. 참고 : 필자의 경우 행 높이가 고정되어 있지 않습니다. 예를 들어 60을 사용했습니다. –

0

cellForRowIndexAtPath : data source 메소드에 한 줄만 씁니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    cell.frame = CGRectMake(0,0,320,60); 

} 
관련 문제