locked
how to add header for section RRS feed

  • Question

  • User306227 posted

    how to add header for section .please find the attachment


    Sunday, April 26, 2020 11:24 AM

Answers

  • User382871 posted

    If you just want to display the time text, remove the GetViewForHeader method code and use TitleForHeader method to add the header content. public override string TitleForHeader(UITableView tableView, nint section) { return keys[section];//return the header text }

    Tutorial: https://docs.microsoft.com/en-us/xamarin/ios/user-interface/controls/tables/populating-a-table-with-data#adding-headers-and-footers

    You could refer to the Populating a Table with Data part project of official sample. https://docs.microsoft.com/en-us/samples/xamarin/ios-samples/workingwithtables/

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 27, 2020 7:56 AM

All replies

  • User382871 posted

    To add header for section, you could rewrite the GetViewForHeader method to return a custom view. ``` public override UIView GetViewForHeader(UITableView tableView, nint section) { UIView view = new UIView();

    view.BackgroundColor = UIColor.Red;
    view.Frame = new CoreGraphics.CGRect(0, 0, 100, 200);
    
    return view;
    

    } ```

    Check the link: https://stackoverflow.com/a/45057243/11083277

    Monday, April 27, 2020 2:23 AM
  • User306227 posted

    Ya i have add this.. But header is not coming as per the screen shot..

    Monday, April 27, 2020 4:29 AM
  • User382871 posted

    If you just want to display the time text, remove the GetViewForHeader method code and use TitleForHeader method to add the header content. public override string TitleForHeader(UITableView tableView, nint section) { return keys[section];//return the header text }

    Tutorial: https://docs.microsoft.com/en-us/xamarin/ios/user-interface/controls/tables/populating-a-table-with-data#adding-headers-and-footers

    You could refer to the Populating a Table with Data part project of official sample. https://docs.microsoft.com/en-us/samples/xamarin/ios-samples/workingwithtables/

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, April 27, 2020 7:56 AM