Skip to content

Instantly share code, notes, and snippets.

@felipeslongo
Last active April 25, 2019 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipeslongo/36d0f7afe2216fb7d8147149038c79ee to your computer and use it in GitHub Desktop.
Save felipeslongo/36d0f7afe2216fb7d8147149038c79ee to your computer and use it in GitHub Desktop.
Garante que o table header view vai ser redimensionado corretamente para encapsular a view atribuida
using UIKit;
namespace App.iOS.Extensions
{
//https://stackoverflow.com/questions/5484493/changing-the-height-of-a-tableheaderview-hides-the-cells/5764819#5764819
public static class UITableViewAtribuirTableHeaderView
{
private static bool VersaoIosBugadaQueNaoAtualizaOTamanhoCorretamenteDoTableHeaderView =>
!UIDevice.CurrentDevice.CheckSystemVersion(9, 0);
public static void AtribuirTableHeaderView(this UITableView @this, UIView view)
{
if (VersaoIosBugadaQueNaoAtualizaOTamanhoCorretamenteDoTableHeaderView)
{
AtribuiTableHeaderViewRespeitandoTamanhoDaViewAtribuida(@this, view);
return;
}
@this.TableHeaderView = view;
}
private static void AtribuiTableHeaderViewRespeitandoTamanhoDaViewAtribuida(UITableView tableView, UIView view)
{
tableView.TableHeaderView = view;
view.SizeToFit();
tableView.TableHeaderView = view;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment