I've spent most of my day trying a number of solutions to get this to work and I've googled lots of stackoverflow answers yet nothing has helped me. The problem is that I have a lot of text being shown and at the end it gets cut off. I can verify this by going to the end and deleting some of the text as the pieces below show up. I've set my table to have a bigger content size which did increase the scroll area but the text view gets cut off. Below the content size I have set for the scroll area is some methods I have tried but none have worked. Now what is odd is I set up a sizeToFit method as well but it worked once then it stopped working. This worked when I changed the height on the text view I have set up in my storyboard then after that it stopped working. It literally is driving me mad.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
tableView.separatorColor = [UIColor clearColor];
tableView.contentSize = CGSizeMake(320, 1800);
self.procedureScrollView.contentSize = (CGSizeMake(320, 1800));
self.procedureText.contentSize = (CGSizeMake(320, 1800));
self.procedureScrollView.scrollEnabled = NO;
self.procedureScrollView.scrollEnabled = YES;
if (indexPath.row < _procedureVariables.count)
return 40.0f;
else {
UIFont *cellFont = [UIFont fontWithName:@"Avenir Next" size:14.0];
CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
NSString *cellText = [NSString stringWithFormat:@"%@ \n\n %@", [_templateDictionary objectForKey:@"indicationText"], [_templateDictionary objectForKey:@"procedureText"]];
CGSize labelSize = [cellText sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height;
}}
Here is the viewWillAppear method
- (void)viewWillAppear:(BOOL)animated{
[self.procedureText setFrame:self.procedureTextFrame];
[self.indicationTextView setFrame:self.indicationTextFrame];
self.reducedIndicationTextHeight = self.indicationTextView.frame.size.height - 180;
self.reducedProcedureTextHeight = self.procedureText.frame.size.height - 180;
self.increasedIndicationTextHeight = self.indicationTextView.frame.size.height + 180;
self.increasedProcedureTextHeight = self.procedureText.frame.size.height + 180;
[self.caseDataTableView reloadData];
}
Here is the sizeToFit method I used.
[self.procedureText sizeToFit];
I've tried countless solutions and none have worked. I've put this code into viewDidAppear, viewDidLoad, etc. Nothing has worked. Any help is very much appreciated!