mono touch绘制带表头的表格

本文介绍了一个使用MonoTouch在iOS设备上实现新闻列表视图的方法。具体包括如何设置导航控制器、组织数据列表、确定表格视图的分区数量及每一区的行数,并自定义了表头视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有不明白的地方欢迎入群 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; }
        }

        //...

    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值