UITextView в UITableViewCell, автокоррекция не может быть отклонена - PullRequest
0 голосов
/ 24 января 2012

У меня есть UITextView внутри UITableViewCell. Он работает, как и ожидалось, за исключением того, что я не могу отклонить всплывающие подсказки об автокоррекции. Вот как выглядит мой -tableView:cellForRowAtIndexPath: метод:

- (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 Ответ

1 голос
/ 24 января 2012

@ Питер Варбо: Я подозреваю следующее:

  • По умолчанию свойство userInteraction UIImageView установлено в NO.Установите его в YES на вашем объекте просмотра изображения баллона.balloon.userInteractionEnabled = YES;

HTH

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...