Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //****** adding delete section button
- CellButton *_sectionButton = (CellButton*)[cell viewWithTag:10];
- _sectionButton.hidden = YES;
- _sectionButton.indexPath = indexPath;
- [_sectionButton addTarget:self action:@selector(sectionDeleteButton:) forControlEvents:UIControlEventTouchUpInside];
- -(void)sectionDeleteButton: (id)sender
- {
- CellButton *_secbtn = (CellButton*)sender;
- NSInteger sectionNumber = _secbtn.indexPath.section;
- [self.tableView beginUpdates];
- [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionNumber] withRowAnimation:UITableViewRowAnimationAutomatic];
- [self.tableView endUpdates];
- [self.tableView reloadData];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- //#warning Potentially incomplete method implementation.
- // Return the number of sections.
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- //#warning Incomplete method implementation.
- // Return the number of rows in the section.
- return [MLControl shared].arrBuyList.count;//1;//[MLControl shared].arrBuyList.count;
- }
- // Override to support editing the table view.
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- // [tableView beginUpdates];
- NSLog(@"indexPath.row=%ld,indexPath.se=%ld",(long)indexPath.row,(long)indexPath.section);
- [[MLControl shared].arrBuyList removeObjectAtIndex:indexPath.row];
- [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
- // [tableView endUpdates];
- } else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement