views:

17

answers:

0

Hi,

I am trying to make 2 switches, one that will add a section with 3 rows and one that will add a row in a existing section.

if (alertSwitch.on == YES) {
  alert = YES;
  [myTable beginUpdates];
  [myTable insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
  [myTable endUpdates];
  [myTable reloadData];


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
 if (NO == alert) {
  return 4;
 } else {
  return 5;
 }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
 if (section == 0) {
  return 3;
 } else if (section == 1){
  return 1;
 } else if (section == 2){
  return 1;
 } else if (section == 3){
  return 1;
 } else if (section == 4 && alert == YES){
  return 3;
 } else {
  return 0;
 }
}

I have looked up lot's of information on the internet, but i still can't show the rows. Can someone help me with this problem?