有不明白的地方欢迎入群 347636249 探讨
private UINavigationController navigationController;
private List<TableItemGroup> ItemsList;public NewsListTwo (UINavigationController nav, List<TableItemGroup> tableGroup)
{
this.navigationController = nav;
this.ItemsList = tableGroup;
}
public override int NumberOfSections (UITableView tableView)
{
return ItemsList.Count;
}
public override int RowsInSection (UITableView tableview, int section)
{
return ItemsList[section].Items.Count;
}
public override UIView GetViewForHeader (UITableView tableView, int section)
{
UIView _view = new UIView (new RectangleF (0, 0, 320, 23));
UIImageView uimg = new UIImageView (UIImage.FromFile (ControlCenter.ImagePath + "channeltitlebg.png"));
uimg.Frame = new RectangleF (0, 0, 320, 23);
_view.AddSubview (uimg);
UILabel lbl = ControlCenter.CreateLbl (new RectangleF (10, 0, 200, 23), ItemsList[section].Header);
lbl.TextColor = UIColor.FromRGB (220, 109, 19);
_view.AddSubview (lbl);
UIButton btn = CreateButton (new RectangleF (260, 0, 60, 23), "更多>>", "", UIColor.FromRGB (232, 94, 0));
btn.Font = UIFont.SystemFontOfSize (12);
btn.TouchUpInside += delegate {
};
_view.AddSubview (btn);
return _view;
}
// public override string TitleForHeader (UITableView tableView, int section)
// {
// return ItemsList[section].Header;
// }
//========================================
public class TableItemGroup
{
/// <summary>
/// 表头
/// </summary>
public string Header { get; set; }
protected List<ArticleModel> items = new List<ArticleModel> ();
public List<ArticleModel> Items {
get { return items; }
set { items = value; }
}
//...
}