2012-01-24 4 views
0

UITableViewCell 안에 UITextView이 있습니다. 예상대로 작동하지만, 팝업되는 자동 수정 제안을 무시할 수 없습니다.UITableViewCell의 UITextView, 자동 수정을 닫을 수 없습니다.

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

    static NSString *messageCellIdentifier = @"MessageCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier]; 

    if (cell == nil) { 

     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
             reuseIdentifier:messageCellIdentifier]; 
    } 

    // Set the background view of the cell to be transparent   
    UIView *backView = [[UIView alloc] initWithFrame:CGRectZero]; 
    backView.backgroundColor = [UIColor clearColor]; 
    cell.backgroundView = backView; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    UIImage *ballonImage = [[UIImage imageNamed:@"ChatBubbleGray.png"] stretchableImageWithLeftCapWidth:24 topCapHeight:15]; 

    NSString *text = @"Touch To Type"; 

    // This imageView will be the background of the UITextView 
    UIImageView *balloon = [[UIImageView alloc] initWithImage:ballonImage]; 

    balloon.frame = CGRectMake(0.0, 0.0, 300, 140); 

    CGRect textViewFrame; 

    textViewFrame.origin.x = balloon.frame.origin.x + 10; 
    textViewFrame.origin.y = balloon.frame.origin.y + 5; 
    textViewFrame.size.width = balloon.frame.size.width - 12; 
    textViewFrame.size.height = balloon.frame.size.height - 15; 

    self.messageTextView = [[UITextView alloc] initWithFrame:textViewFrame]; 
    self.messageTextView.backgroundColor = [UIColor clearColor]; 
    self.messageTextView.returnKeyType = UIReturnKeyDefault; 
    self.messageTextView.editable = YES; 
    self.messageTextView.scrollEnabled = YES; 
    self.messageTextView.autocorrectionType = UITextAutocorrectionTypeYes; 
    self.messageTextView.autocapitalizationType = UITextAutocapitalizationTypeSentences; 
    self.messageTextView.delegate = self; 
    self.messageTextView.text = text; 
    self.messageTextView.font = [UIFont systemFontOfSize:14.0]; 

    [balloon addSubview:self.messageTextView]; 

    [cell.contentView addSubview:balloon]; 

    return cell; 
} 

답변

1

@ 피터 Warbo : 이것은 내 -tableView:cellForRowAtIndexPath: 방법은 모습입니다 나는 다음과 같은 의심하고있어 기본적있는 UIImageView의 userInteraction 속성으로

  • 은 NO로 설정됩니다. 풍선 이미지보기 객체에서 YES로 설정하십시오. balloon.userInteractionEnabled = YES;

HTH

+0

저런, 그 단순. 무리 감사! –

+0

BTW, userInteractionEnabled를 UIImageView로 설정하십시오. 내 UITableViewDelegate 메소드'-tableView : didSelectRowAtIndexPath :'가 트리거되지 않습니다. 어떻게 이것을 극복 할 수 있습니까? –

+0

UITextView 개체의 배경 이미지로 풍선보기를 설정하려는 경우 다음을 권장합니다. UITextView * textView = [[UITextView alloc] initWithFrame : CGRectMake (0, 0, 300, 140)]]; [textView setBackgroundColor : [UIColor colorWithPatternImage : [UIImage imageNamed : @ "balloon.png"]]]; textView.contentInset = UIEdgeInsetsMake (10,10,0,0); [cell.contentView addSubView : textView]; – Jimit

관련 문제