SDK iOS. . , , .
, . .
tableView:didEndReorderingRowAtIndexPath:, (). :
- (void)tableView:(UITableView *)tableView didEndReorderingRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section]
withRowAnimation:UITableViewRowAnimationNone];
}
, ( ).
( reloadRowsAtIndexPaths:withRowAnimation:. , . / .)
, private delegate, , , ( moveRowAtIndexPath:toIndexPath:). .
CALayer, CATransaction, , . ( QuartzCore.framework .) :
UITableView + NicelyMoves.h
#import <UIKit/UIKit.h>
@interface UITableView (NicelyMoves)
- (void)nicelyMoveRowAtIndexPath:(NSIndexPath *)indexPath
toIndexPath:(NSIndexPath *)newIndexPath;
@end
UITableView + NicelyMoves.m
#import <QuartzCore/QuartzCore.h>
#import "UITableView+NicelyMoves.h"
@implementation UITableView (NicelyMoves)
- (void)nicelyMoveRowAtIndexPath:(NSIndexPath *)indexPath
toIndexPath:(NSIndexPath *)newIndexPath
{
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[self reloadRowsAtIndexPaths:@[indexPath, newIndexPath]
withRowAnimation:UITableViewRowAnimationNone];
}];
[self moveRowAtIndexPath:indexPath toIndexPath:newIndexPath];
[CATransaction commit];
}
@end
, moveRowAtIndexPath:toIndexPath:, nicelyMoveRowAtIndexPath:toIndexPath:. , :
#import "UITableView+NicelyMoves.h"
@implementation YourTableViewController
- (void)moveTheRow
{
NSIndexPath *from = [NSIndexPath indexPathForRow:0 inSection:0];
NSIndexPath *to = [NSIndexPath indexPathForRow:2 inSection:0];
[self.tableView nicelyMoveRowAtIndexPath:from toIndexPath:to];
}
@end