Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. //****** adding delete section button
  2. CellButton *_sectionButton = (CellButton*)[cell viewWithTag:10];
  3. _sectionButton.hidden = YES;
  4. _sectionButton.indexPath = indexPath;
  5. [_sectionButton addTarget:self action:@selector(sectionDeleteButton:) forControlEvents:UIControlEventTouchUpInside];
  6.  
  7. -(void)sectionDeleteButton: (id)sender
  8. {
  9. CellButton *_secbtn = (CellButton*)sender;
  10. NSInteger sectionNumber = _secbtn.indexPath.section;
  11. [self.tableView beginUpdates];
  12. [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionNumber] withRowAnimation:UITableViewRowAnimationAutomatic];
  13. [self.tableView endUpdates];
  14. [self.tableView reloadData];
  15.  
  16. }
  17.  
  18. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  19. //#warning Potentially incomplete method implementation.
  20. // Return the number of sections.
  21. return 1;
  22. }
  23.  
  24. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  25. //#warning Incomplete method implementation.
  26. // Return the number of rows in the section.
  27. return [MLControl shared].arrBuyList.count;//1;//[MLControl shared].arrBuyList.count;
  28. }
  29.  
  30. // Override to support editing the table view.
  31. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  32. if (editingStyle == UITableViewCellEditingStyleDelete) {
  33. // Delete the row from the data source
  34. // [tableView beginUpdates];
  35. NSLog(@"indexPath.row=%ld,indexPath.se=%ld",(long)indexPath.row,(long)indexPath.section);
  36. [[MLControl shared].arrBuyList removeObjectAtIndex:indexPath.row];
  37. [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  38. // [tableView endUpdates];
  39. } else if (editingStyle == UITableViewCellEditingStyleInsert) {
  40. // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement