I am trying to resize a UITextView that I have in a UITableViewCell. I also want to resize a UITableViewCell. My UITableViewCell resizes correctly, but a UITextView does not. The result is only two lines, and not the size to the desired size. When I initialize it in the cellForRowAtIndexPath method, it looks like this:
UITextView *notesTextView = [[UITextView alloc] initWithFrame:CGRectMake(83, 12, TEXTVIEW_WIDTH, 22)]; notesTextView.tag = TEXTVIEW_TAG; notesTextView.delegate = self; [cell.contentView addSubview:notesTextView];
When I try to change it in the textView delegate method, I do:
CGSize size = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(TEXTVIEW_WIDTH, 460) lineBreakMode:UILineBreakModeWordWrap]; NSLog(@"size: %@", NSStringFromCGSize(size));
So what happens is to resize the View table correctly, and although the textView frame has the correct size (for example, {{83, 12}, {197, 120}}), the textView has only 2 rows. This does not result in a UITableViewCell size, as I expected.
EDIT: When I try to just change the frame size for a UITextView in a regular UIView that is not a UITableViewCell, it works fine. Therefore, I am not sure what is different in this case.
source share