While writing a UITableView in iOS8 I've implemented swipe left/right gestures similar to that in Mail. I would now like to implement a cell that slides down below the cell which the user has just swiped left and tapped a button on. Can anyone point me in the right direction?
You need to add the row that should slide out to the data model (UITableViewDataSource) of your UITableView, then tell the tableview section to update with an animation:
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop];
[self.tableView endUpdates];
Related
I have a single cell that is normally 60pt high. When tapped, this cell expands to 160pt and exposes a label with more text.
When I tap the cell, didSelectRowAtIndexPath is called, and in there I call:
[self.tableView reloadRowsAtIndexPaths:#[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
This works fine ONLY after the first tap. The first time I tap the cell, it will immediately expand to 160pt without any animation. Every successive tap will correctly animate the cell between the two heights.
Anyone experience this?
I have a UITableView that is made up of sections with 1 row in each section. This is done so that I can get buffer space between each row. When the user deletes a row, they are de facto deleting the whole section.
My row deletion code in commitEditingStyle is:
[self.habitsToView removeObjectAtIndex:[indexPath section]];
[tableView beginUpdates];
[tableView deleteSections:[NSIndexSet indexSetWithIndex:[indexPath section]] withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
But when a row is deleted, the animation is wrong. The row itself slides off to the left, and the delete button slides upwards. This happens no matter what value I use for withRowAnimation
Anyone know what could be causing the strange animation?
I have a Table view. When the user swipes to the left the delete button appears and he is able to remove this entry. But now I've made some strange experiences with the row animation. When the user then clicks on the delete button it stays there but the normal cell is moved. After the cell content view has disappeard the delete button exits also.
What's the problem here?
[[eventDataDictionary objectForKey:key] removeObject:[sortedArray objectAtIndex:indexPath.row]];
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationMiddle];
[tableView endUpdates];
Thanks and best regards from Germany,
Chris
I don't think you need beginUpdates, endUpdates. deleteRowsAtIndexPaths: has its own animation parameter. Just remove the begin~end end try again.
I have set up my table view with 6 static cells and I'm trying to have one cell (the third cell) expand upon selection. The problem is, it resizes after calling reloadRowsAtIndexPaths:, but then the cell appears blank. If I scroll the cell out of view, it shows the contents properly.
When I call [tableView reloadData] the cell isn't blank, but then, I can't enjoy the animation.
Does anyone know why this is so?
Well if you set the height for a row then you need to reload the content of the cell NOT the content of the whole table. If you call [tableview reloadData] then it simply means that you redraw the whole table(without the height correction).
To reload a single cell in the table:
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
I don't know if I was the only one having the problem with a blank static cell issue.
I stumbled on a solution and that is calling [tableView reloadData] after calling reloadRowsAtIndexPaths:
Reload the respective table view row using the main thread.
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
// Reload the respective table view row using the main thread.
[self.tblFiles reloadRowsAtIndexPaths:#[[NSIndexPath indexPathForRow:index inSection:0]]
withRowAnimation:UITableViewRowAnimationNone];
}];
In one tableView I have 4 rows on section0 and 3 rows on section1. If I tap the row at indexPath (1,2) another row appears with a UIPickerView inside it. I want the tableView to scroll so that the pickerView moves at the top of the screen. To do that I implemented
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
but this only scrolls it up a little bit, not much.
Is there anything I'm missing here? Any help would be much appreciated. Thanks in advance.
well, that's embarasing. As it so happens you do not need the above code to be between
[self.tableView beginUpdates];
...
[self.tableView endUpdates];
I'm gonna leave the answer here in case somebody has the same issue.