objective c - Number of Rows in UITableView Needs to Differ after Delete -
I have a table with multiple sections. When there is no line in a given section, I come back from 1 to numerOfRowInSection
and then make some default text. I do not allow this row to be selected or edited.
The problem is that this section allows the removal of lines when the data is (again I disable it when the data is not present and I'm displaying my default text). However, suppose that this section contains a line of actual data. When the user deletes this line, then he should reload the table and my default text will be shown because the data for this section is no longer present. What really happens is an AP terminal error because it is expecting 0 rows after deletion (1 row ago, delete 1 row, 0 line result). . In my code though when the rows 0 is mentioned as I do not have math work and the error returns everything stops 1
Question: How can I put a default line when the table is empty , But allow it to be removed so that when the last line of data is removed it will not allow any of my line of the default text from any row, as this hope
code for Delete: < / P>
- (zero) tableView: (UITableView *) tableView commitEditingStyle: (UITableViewCellEditingStyle) editingStyle forRowAtIndexPath: (NSIndexPath *) indexPath {if (editingStyle == UITableViewCellEditingStyleDelete} {[self deleteFav: indexPath.row] ; [Delete TableViewAttendAxPath: @ [IndexPath] with Row Animation: UITDViewAnimationFed]; }}
To handle the number of code rows and defaults:
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) Section {if (section == 0) comes back [self. Channelmade array count]; Otherwise if (section == 1) ([self.favChannelIDArray count]> gt; return) [self.favChannelIDArray count]; And return 1; }
Error:
2014-07-31 19: 47: 19.194 ephIM [3183: 60B] * Exception to 'NSInternalInconsistencyException', due to: 'Invalid update: Invalid number of rows in section 1 after updating the number of rows contained in that section before updating the number of rows contained in an existing section (1) Must be equal (1), plus or minus inserted or that segment (0, inserted 1) and plus or minus The number of rows removed from the number of rows or moved out of that section (moved to 0, went out 0). '
Your code is not taking into account your additional line when there are no general lines It needs to be added:
- (zero) tableview: Send the table view (UITableView *) Item style: (UITableViewCellEditingStyle) ROATI and API for editing style: (NSIndexPath *) indexPath {if (editingStyle == UITableViewCellEditingStyleDelete) {[auto delete Fav: indexPath.row]; [Table view start update]; [TableView deleteRowsAtIndexPaths: @ [indexPath] withRowAnimation: UITableViewRowAnimationFade]; (IndexPath.section == 1 & amp; self.favChannelIDArray.count == 0) If {// it contains the table for inserting the "dummy" row you want [tableView insertRowsAtIndexPaths: @ [[NSIndexPath indexPathForRow : 0 insection: index paths.sections]] with Row Animation: UITableViewRowAnimationFade]; } [Table view end update]; }}
Comments
Post a Comment