簡體   English   中英

用UITextView替換UITableViewCell文本

[英]Replace UITableViewCell text with UITextView

在我的應用程序中,我將UITextView設置為UITableViewCell的contentView,以便您可以寫入其中。 這是我的設置方式:

        UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(cell.bounds.origin.x, cell.bounds.origin.y, cell.contentView.frame.size.width, cell.contentView.frame.size.height)];
        [textView setFont:[UIFont fontWithName:@"Arial" size:18.0f]];
        [textView setBackgroundColor:[UIColor blueColor]];
        [textView setAutocorrectionType:UITextAutocorrectionTypeNo];

        textView.text = cell.textLabel.text;
        textView.delegate = self;
        cell.textLabel.text = @"";
        self.textView = textView;
        [cell.contentView addSubview:textView];
        [textView becomeFirstResponder];

我想設置textView.text權,其中cell.textlabel.text是,但它是一點點進一步向左和向上然后單元格文本以前。 如何設置單元格的文本對齊方式和/或文本偏移量到UITextView,以便文本位於同一位置?

yourUITextView.contentInset = UIEdgeInsetsMake(-4,-8,0,0); // Mess around with these values

要么...

設置textView的框架

    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(5, 0, cell.contentView.frame.size.width - 10, cell.contentView.frame.size.height)];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM