2014-04-11 18 views
1

사용자가 고정하고있는 다른 UITextView에 쓰려는 내용을 수집하기 위해 UITextView (단추의 누를 때 표시됨)가 나타납니다. UITextView의 높이 (고정 된 크기)의 크기를 조정하고 사용자가 다른 (모달) UITextView에 입력 한 텍스트를 넣습니다. 그러나, 줄 바꿈 (모달 UITextView에서했던 것처럼) 대신 고정 된 UITextView가 텍스트를 줄 바꿈하지 않습니다 ... 고정 된 UITextView가 텍스트를 줄 바꿈하게하려면 어떻게해야합니까? 나는있는 NSString의 테이블 textsToDisplay에서 사용자가 입력 한 텍스트를 저장UITextView의 줄 바꿈 텍스트 (줄 바꿈 모드)

textsToDisplay[index] = [enterText text]; 

    NSInteger _stringTotalLength=[[enterText text] length]; 
    NSMutableAttributedString *attSt=[[NSMutableAttributedString alloc] initWithString:[enterText text]]; 
    [attSt addAttribute:NSFontAttributeName 
        value:[UIFont fontWithName:@"Helvetica" size:15.0] 
        range:NSMakeRange(0, _stringTotalLength)]; 

    float height3 = ceil(attSt.size.height); 

    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 
    if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){ 
     cellSizes[index] = CGSizeMake(screenWidth-6,height3+10); 
    }else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){ 
     cellSizes[index] = CGSizeMake(screenHeight-25,height3+10); 
    } 

:

여기 내 코드입니다. 나는 다음과 같은 코드를 입력 할 수있는 uitextview을 만들

- (UICollectionViewCell*) collectionView:(UICollectionView *)collectView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 
    NSMutableAttributedString *attSt=[[NSMutableAttributedString alloc] initWithString:textsToDisplay[index]]; 
    NSInteger _stringTotalLength=[textsToDisplay[index] length]; 
    [attSt addAttribute:NSFontAttributeName 
        value:[UIFont fontWithName:@"Helvetica" size:15.0] 
        range:NSMakeRange(0, _stringTotalLength)]; 
    cell.textView.attributedText =attSt; 

: 여기

float width = 500.0f; 

    enterText = [[UITextView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-(width)/2, self.view.frame.size.height/2-200, width, 400)]; 
    NSMutableAttributedString *attSt=[[NSMutableAttributedString alloc] initWithString:questionCell.textView.text]; 
    NSInteger _stringTotalLength=[questionCell.textView.text length]; 
    [attSt addAttribute:NSFontAttributeName 
        value:[UIFont fontWithName:@"Helvetica" size:15.0] 
        range:NSMakeRange(0, _stringTotalLength)]; 
    enterText.attributedText = attSt; 
    enterText.tag = 92; 
    enterText.backgroundColor = [UIColor whiteColor]; 
    enterText.alpha = 1; 
    enterText.delegate = self; 
    [self.view addSubview:enterText]; 

와 내가 어떻게되고 나는 그의 세포 고정 UITextView 포함하고 나는 다음과 같은 방법으로 텍스트를 설정 UICollectionView를 사용하고

textView = [[UITextView alloc]initWithFrame:CGRectMake(50, 0, widthLabel-50, 50)]; 
     textView.userInteractionEnabled = YES; 
     textView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight; 
     textView.backgroundColor = [UIColor clearColor]; 

및 I는 다음과 같이 구성합니다 : 셀에 uitextview을 만들

cell.textView.frame = CGRectMake(50, 0, cellSizes[index].width-50, cellSizes[index].height); 
+0

래핑은 UITextView의 속성에 의한 제어입니다. 두 사람이 어떻게 구성되었는지 확인할 수 있습니까? NIB 또는 코드에서 작성하고 있습니까? – sha

+0

제 질문을 편집하여 프로그램 방식으로 작성하는 방법을 보여줍니다. – Stoli

답변

1

uitextview로 줄 바꿈을하기에는 너무 복잡하기 때문에 필자는 각 uicollectionviewcell에서 uilabel을 사용했다.