Reputation: 225
I have tried all the possible way.I used UITableView in that custom cells I have two label.I want to auto size that row if the text is more.It is not happening.Please help anyone know the answer.Please check the code and screenshot.
Note : This code is in Xamrin.iOS. You can answer in swift too
[Export("tableView:estimatedHeightForRowAtIndexPath:")]
public nfloat EstimatedHeight(UITableView tableView, NSIndexPath indexPath)
{
return UITableView.AutomaticDimension;
}
[Export("tableView:heightForRowAtIndexPath:")]
public nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
return UITableView.AutomaticDimension;
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
notificationTableView.EstimatedRowHeight = 200;
notificationTableView.RowHeight = UITableView.AutomaticDimension;
notificationTableView.ReloadData();
notificationTableView.LayoutIfNeeded();
}
Upvotes: 0
Views: 285
Reputation: 1298
Have you tried assigning values to cell using getter and setter methods?
public string DescriptionTxt
{
get { return labelCustomerDescription.Text; }
set { labelCustomerDescription.Text = value; }
}
You can also try layout if needed for the cell, after assigning the text to the cell.
cell.SetNeedsDisplay();
cell.LayoutIfNeeded();
Upvotes: 1
Reputation: 1076
your top and bottom component must has top and bottom constraints.
like, you must need to provide bottom constraint to label,
and write,
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath)-> CGFloat {
return UITableViewAutomaticDimension
}
Upvotes: 0