I am using UITableViewController
instead detailView to show one entity details. I populated one row of data from PFQuery in my viewDidLoad
method.
If you are using autolayout. Add top, left and right constrain in to your label.
Then in heightForRowAtIndexPath
create your cell
static NSString *simpleTableIdentifier = @"DetailsDesecriptionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
Set values to label and calculate size of the label after setting the value
[cell layoutIfNeeded];
return cell.label.frame.origin.y+cell.label.frame.size.height;
This will give you the exact hight of the label and your cell height will be same
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = @"DetailsDesecriptionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
cell.titleLabel.text=@"YOUR TEXT";
[cell layoutIfNeeded];
return cell.titleLabel.frame.origin.y+cell.titleLabel.frame.size.height;
}