Reputation: 10974
I have UITableVIew
table.
I implemented deleting in method tableView:commitEditingStyle:forRowAtIndexPath:
of UITableViewDataSource
Protocol.
All work fine here. Useful question on subject here Deleting table row with animation using core data .
But every cell shows timer which count down and I have issue with this.
I use NSTimer
in following way:
timer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self
selector:@selector(updateTickerHandler:) userInfo:nil repeats:YES];
...
- (void)updateTickerHandler:(NSTimer*)timer
{
[tableView reloadData];
}
When user swipes to delete timer, button "Delete" disappear when [tableView reloadData];
called.
I want to implement updating timer count down values on table cells which allows user to use swipe with "Delete" smoothly.
How to achieve this?
Upvotes: 0
Views: 1190
Reputation: 10974
I was not able to obtain working behaviour with the call:
[tableView reloadData];
The working solution is to update cell components manually and not to call [table reloadData]
Code of updateTickerHandler:
could be updated in the following way:
- (void)updateTickerHandler:(NSTimer*)timer
{
[tableView beginUpdates];
// select visible cells only which we will update
NSArray *visibleIndices = [tableView indexPathsForVisibleRows];
// iterate through visible cells
for (NSIndexPath *visibleIndex in visibleIndices)
{
MyTableCell *cell = (MyTableCell*)
[tableView cellForRowAtIndexPath:visibleIndex];
// add here code to fill `cell` with actual values
// visibleIndex can be used to retrieve corresponding data
...
}
[tableView endUpdates];
}
Upvotes: 3
Reputation: 374
- (void)updateTickerHandler:(NSTimer*)timer
{
[Table beginUpdates];
[Table reloadData];
[Table endUpdates];
}
Upvotes: 0