Ranjit, it is not necessary to use UIStackView
for this case,
You can easily handle this issue without using UIStackView
. Here is a tip for you.
Before you find the Estimated row height, you should apply some Autolayout tricks.
You simply add height and width constraint for that UIImageView
. And add a Leading space and Top space for UIImageView
.
Then add a Trailing space and Leading space for the first label in the cell. And align top to UIImageView
.
Add top, leading and trailing space for the 2nd label.
Add height and width for the calendar image and add top space to 2nd label then align leading to 2nd label (right click and drag to 2nd label from calendar image). Add trailing space to 3rd label.
On 3rd label add Top space to 2nd label or center align to calendar image. Add trailing space to container and Bottom space too.
On 4th label (under the UIImageView
) you should add a trailing space to calendar image and center align to calendar image. Add leadings space to container.
Make sure all the big data holding labels had number of lines is "0".
Now all the components are satisfied with x and y values. It helps to find the estimated row height for your tableview.
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
Now your table view can height choose automatically. Hope you got the ideas.