2014-01-10 2 views
1

사용자 정의 셀을 만들었으므로 contentView의 프레임을 변경하고 싶습니다. 내 셀은 CustomCell입니다. cellforrowatindexpath에서 contentView 프레임을 변경하는 방법은 무엇입니까?

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

    NSLog(@"hey"); 
    static NSString *CellIdentifier = @"CustomCellReuseID"; 

    AbcCustomCell *cell = [tabel_Abc dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     cell = [[AbcCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    NSString *name= [arrayTabel_Abc objectAtIndex:indexPath.section]; 

    [cell setBackgroundColor:[UIColor clearColor]]; 


    [cell.label_CellList setText:name]; 

    cell.contentView.frame = CGRectMake (100,0,500,20); 


    return cell; 
    } 

I는이 사용 cell.contentView.frame = CGRectMake (100,0,500,20); 하지만 나를 위해 작동하지 않습니다. customCell의 contentView를 변경하고 싶습니다. 아무도 나를 안내 할 수 있습니까 ?? 미리 감사드립니다.

+0

자동 레이아웃을 사용하고 있습니까? –

+0

예 UITableVIewCustomCell에서 AutoLayout을 사용하고 있습니다. – Sami

답변

0

셀의 contentView에 대한 프레임을 다시 지정해야합니다.

CGRect oldFrame = cell.contentView.frame; 
cell.contentView.frame = CGRectMake(oldFrame.origin.x, 
           oldFrame.origin.y, 
           oldFrame.size.width + 20, 
           oldFrame.size.height); 

또는 당신은 당신은있는 contentView을 변경할 수 없습니다 정의 셀

+0

코드를 시도했지만 작동하지 않습니다. – Sami

+0

레이아웃 셀 뷰에서 contentview를 변경하기 위해 맞춤 셀을 사용해보세요. – sabeer

1

를 사용할 수 있습니다. UITableViewCell contentView의 높이는 – tableView:heightForRowAtIndexPath: 대리자 메서드에 의해 결정되며 폭은 ​​tableView의 너비입니다.

contentView의 하위보기로보기를 추가하고보기의 프레임을 변경할 수있는 경우

0

셀의 contentView 프레임을 변경할 수 없습니다.

tableView:heightForRowAtIndexPath: 

그러나 너는 너비를 변경할 수 없습니다.

또한 원하는 경우 구분선이 큰 것처럼 만들려면보기를 사용할 수 있습니다.

UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width - paddingX*2, 1)]; 
    separatorLineView.backgroundColor = [UIColor redColor]; 

[cell.contentView addSubview:separatorLineView]; 

바꿀 범위를 벗어난 프레임을 좀 더 구체적으로 지정할 수 있습니까?

관련 문제