开发者

UITextView inside a UITableViewCell

I have a UITextView inside a custom UITableViewCell. The problem im having is related to resignFirstResponder. When resignFirstResponder is called and the UIkeyboard is dismissed the UITextView scrolls up one line which makes the input only half visible at the top of the cell.

Have I missed something in the following code when I create the UITextView?

            if (indexPath.row == 0) {
            // Load the cell with the comment textView 

            cell = (DetailCellViewController *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
            if (cell == nil) {
                NSArray *topLevelObjects = [[NSBundle mainBundle]
                                            loadNibNamed:@"DetailCellView3" 
                                            owner:nil 
                                            options:nil];

                for (id currentObject in topLevelObjects) {
                    if ([currentObject isKindOfClass:[UITableViewCell class]]) {
                        cell = (DetailCellViewController *) currentObject;
                        break;
                    }
                }
            }       
            self.textView = [[UITextView alloc] initWithFrame:cell.contentView.bounds];
            self.textView.backgroundColor = [UIColor clearColor];
            self.textView.textColor = [UIColor blackColor]; 
            self.textView.returnKeyType = UIReturnKeySend;
            self.textView.enablesReturnKeyAutomatically = YES;
            self.textView.editable = YES;
开发者_Python百科            self.textView.scrollEnabled = YES;
            self.textView.opaque =YES;
            self.textView.clipsToBounds = YES;
            self.textView.autocorrectionType = UITextAutocorrectionTypeNo;
            self.textView.delegate = self;
            self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
            [cell.contentView addSubview:textView];
            [textView release];

            return cell;


Set self.textView.contentInset = UIEdgeInsetsZero;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜