1

私のアプリでは、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 に設定するにはどうすればよいですか?

4

1 に答える 1

0
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)];
于 2012-12-05T13:26:14.330 に答える