Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

GetViewForHeader works in the simulator but not working on the device

$
0
0

So i have a GetViewForHeader override and it works great in the simulator. When I debug the app on the device (both iPad and iPhone) no styling is applied. There is no error and the GetViewForHeader code is definitely NOT being run. TitleForHeader etc is tho. Odd!

        public override string TitleForHeader (UITableView tableView, int section)
    {
        return tableItems[section].Name;
    }

    public override UIView GetViewForHeader(UITableView tableView, int section)
    {
                    // THIS DONE NOT FIRE ON THE DEVICE - DOES ON THE SIMULATOR
        return BuildSectionHeaderView(tableItems[section].Name);
    }

    public static UIView BuildSectionHeaderView(string caption) {
        UIView view = new UIView(new System.Drawing.RectangleF(0,0,320,20));
        view.BackgroundColor = UIColor.White;

        UILabel label = new UILabel();
        label.Opaque = false;
        label.TextColor = UIColor.FromRGB (190, 0, 0);
        label.Font = UIFont.FromName("Helvetica-Bold", 16f);
        label.Frame = new System.Drawing.RectangleF(5,10,315,20);
        label.Text = caption;
        view.AddSubview(label);
        return view;
    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>