0

I am trying to add a Footer view with button in my table view. I found this code online

public override UIView GetViewForFooter(UITableView tableView, int sectionIndex)
{
    // Write a method to get the proper Section via the sectionIndex
    var section = GetSection(sectionIndex);
if (section != null)
{
    if (section.FooterView == null && !string.IsNullOrEmpty(section.FooterText))
    {
             // Create your FooterView here 
        section.FooterView = CreateFooterView(tableView, section.FooterText);
    }

    return section.FooterView;
}

return null;
}

I dont know what GetSection method is? I am having error "The name GetSection does not exist in the current context" .

I couldn't find any proper documentation on MonoTouch site as well.

Help is appreciated.

User382
  • 864
  • 19
  • 42
  • GetSection is probably a method you're suppose to write yourself, or a method that is implemented somewhere else in the sample you have found. – NilsH Mar 28 '13 at 16:22
  • I agree that i have to write GetSection method but i dont know what should i write in it. Other worlds what parameters it takes and what it returns. – User382 Mar 28 '13 at 16:32
  • We're missing some context here. Are you using MonoTouch.Dialog? Where have you found the example? – NilsH Mar 28 '13 at 16:36
  • I am not using MonoTouch.Dialog. I guess it is related to MonoTouch.Dialog, right? I wanna do it without MonoTouch.Dialog.... – User382 Mar 28 '13 at 17:21

1 Answers1

0

The example code you have is probably a MonoTouch.Dialog example. If you're not using MonoTouch.Dialog, simply return an appropriate UIView from this method. Something like:

public override UIView GetViewForFooter(UITableView tableView, int sectionIndex) {
    var myFooter = new UIView(); // Or some other class extending UIView, depending on what you want to do
    // Add SubViews and style the view
    return myFooter;
}

If you have more than one section in the table view, you can create different footers for each section by taking the sectionIndex parameter into consideration. For more information, check the documentation

NilsH
  • 13,705
  • 4
  • 41
  • 59