Are you using MonoTouch.Dialog, or normal UITableView stuff?

if it's the latter, I suggest you spend 5 mins and learn a small
amount of objc. The code in that SO post is... well, REALLY basic.

eg

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
///it's the first row of any section so it would be your custom section header

///put in your code to toggle your boolean value here
mybooleans[indexPath.section] = !mybooleans[indexPath.section];

///reload this section
[self.tableView reloadSections:[NSIndexSet
indexSetWithIndex:indexPath.section]
withRowAnimation:UITableViewRowAnimationFade];
  }
}

(sorry, the formatting is going to be out)

In your UITableViewSource derived class

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
  if (indexPath.Row == 0)
  {
    //change the state of the row that was tapped
    mybooleans[indexPath.Section] = !mybooleans[indexPath.Section];

    //when you reload all the sections, they will look at the
mybooleans list to work out if they need to show themselves expanded
or not
    tableView.ReloadSections(NSIndexSet.FromIndex(indexPath.Section),
UITableViewRowAnimation.Fade);
  }
}


They are doing it differently - there is no ACTUAL header, they just
have a normal cell as the first item, and that one is the "header"
(rather than using the built in header) - then you can tap it, and it
expands or contracts.

You could do that with a normal header, by putting views into it and
hooking something off them, but I think this might be easier. That
said, this method would not keep the header at the top when you are
scrolling within a a section - it would scroll off the top like
normal.


On 13 May 2013 12:15, krisha <krishama...@gmail.com> wrote:
> and sample Link is
> :http://stackoverflow.com/questions/1938921/expand-collapse-section-in-uitableview
>
>
>
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/Expand-and-Collapse-UITableView-Section-tp4658301p4658303.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> MonoTouch@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
MonoTouch@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to