public override float GetHeightForHeader(UITableView tableView, int sectionIndex)
{
if (Sections.Count > sectionIndex && Sections.ContainsKey(sectionIndex))
{
var section = Sections[sectionIndex];
if (section != null && !string.IsNullOrEmpty(section.HeaderText))
{
var indentation = UIDevice.CurrentDevice.GetIndentation();
var width = tableView.Bounds.Width - (indentation * 2);
using (var headerLabel = new UILabel())
{
headerLabel.Font = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize);
var size = headerLabel.StringSize(section.HeaderText, headerLabel.Font);
var height = (float)Math.Floor((float)(size.Height * (headerLabel.Font.NumberOfLines(section.HeaderText, width) + 0.5))) + 1;
return height;
}
}
}
return 0;
}