2013-07-05 2 views
1

UITableview의 모든 셀에 UITextView이 있습니다. 텍스트보기의 높이가 동적으로 증가하고 있습니다. 텍스트보기 크기가 커짐에 따라 해당 셀의 높이를 늘리고 싶습니다. 나는 특정 셀의 HIGHT를 늘려야 // 여기UITextView에서 텍스트를 입력 할 때 동적으로 UITableViewcell 확장

-(BOOL)textView:(UITextView *)textView1 shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text 
    { 

     NSLog(@"textTag%d",textView1.tag); 

     NSString *stringToSave = [textView1.text stringByReplacingCharactersInRange:range withString:text]; 
     NSLog(@"Save me: %@", stringToSave); 

    CGFrame*frame =textView1.frame; 
     frame.size.height = textView1.contentSize.height; 
     textView1.frame = frame; 

로 쓰고 있어요.

if([text isEqualToString:@"\n"]) 
    { 
     [textView1 resignFirstResponder]; 
    } 
    return YES; 
} 
+0

- (CGFloat)있는 tableView : (jQuery과 *)있는 tableView heightForRowAtIndexPath : (NSIndexPath *) indexPath – Jitendra

답변

1

이러한 라인 삽입 셀의 높이를 변경

CGFrame*frame =textView1.frame; 
     frame.size.height = textView1.contentSize.height; 
     textView1.frame = frame; 

그리고 heightForRowAtIndexPath 방법하여

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(indexPath.row == cellIndex) 
    { 
     return newHeight; 
    } 
    return regularHeigh; 
} 
+0

나는이 방법은 오류가 어떤 오류 – user1969021

+0

을 보여주는를 쓰고 있어요? 게시하십시오. –

+0

올바른지 ([self tableView : idationFlowTbl heightForRowAtIndexPath : 0]) { return 100; [idationFlowTbl beginUpdates]; [idationFlowTbl endUpdates]; } – user1969021

0

세포의 높이를 NSMutableArray에 매핑 할 수 있다고 생각합니다. 배열에는 사용자가 가지고있는 표준 높이가 포함됩니다.

indexPath.row으로 UITextView에 태그를 지정하면 배열에서로드 할 항목을 알 수 있습니다.

그리고 텍스트 뷰의 높이에 따라 배열의 값을 재정의 할 수 있습니다. 당신의

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return [[mycellsizearray objectAtIndex:indexPath.row]floatValue]; 
} 

에서 다음

지금 당신은 당신의 요구에 따라 높이를 가져야한다.

관련 문제