hpique / hpreordertableview Goto Github PK
View Code? Open in Web Editor NEWDrop-in UITableView replacement to reorder cells with long press on any part of the cell
License: Apache License 2.0
Drop-in UITableView replacement to reorder cells with long press on any part of the cell
License: Apache License 2.0
Hi hpique, thanks a lot for this wonderful tableview. While playing around with the demo app, I found a pretty serious bug... I have made gif demonstrating the same.
When I long press on a cell and then move it around very quickly (in both directions - up and down), the ordering of the other cells gets messed up.
For example, in the gif above, look at the cell 4. It gets stuck to the cell that I am currently dragging around. And when I leave the cell 1, a blank space is found where actually the cell 4 should have been.
Also, when dragging the cell over long distance (in both directions, quickly), the ordering of other cells in the table view gets haphazard. If this bug is difficult to reproduce, please do ask to clarify, I'll be happy to make other gifs with more detailed description to sort this bug out.
Thanks again, hpique!
Hey, firstly, thank you so much for this project, great time saver.
I subclassed the tableview so that I could reuse it later. Unfortunately this caused a funny side effect: when I am in reordering mode, the reordered cell leaves behind a copy of itself. So instead of the white empty cell, you actually see a copy of the cell. Do you know why this might happen?
I was able to get rid of this effect by not subclassing the tableview, but that way did not allow me to override functions like canMoveRowAtIndexPath or canEditRowAtIndexPath. Any help would be greatly appreciated. Thanks!
Is there a way to use this control with a UITableViewController instead?
Thank you.
Hello,
I want to be able to reorder cells within a particular section. As my tableview has multiple sections, I can't use this pod as it only allows 1 section per tableview. How can I achieve what I want?
Thanks
To reproduce:
tableView: targetIndexPathForMoveFromRowAtIndexPath: toProposedIndexPath:
in table view delegateThe crash is in HPReorderTableView.m, - (void)updateCurrentLocation:(UILongPressGestureRecognizer *)gesture
. toIndexPath
is nil which results in a crash. A possible fix is:
if ([self.delegate respondsToSelector:@selector(tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:)])
{
if (toIndexPath == nil) {
return;
}
toIndexPath = [self.delegate tableView:self targetIndexPathForMoveFromRowAtIndexPath:_reorderInitialIndexPath toProposedIndexPath:toIndexPath];
}
Add this code on Viewdidload and the try
self.tableView.estimatedRowHeight = 10;
self.tableView.rowHeight = UITableViewAutomaticDimension;
Hi hpique,
thanks for this fantastic library, it works great and saved me a lot of time.
I don't have any problem regards the functionality of the library, I'm able to move the cells and trigger the associated action, my issue is a cosmetic issue: when a cell is selected by a long press gesture and is moving it becomes BLACK... when the cell is just selected the color is BLUE
How can I change this color and make it transparent ( or any other color)?
This is the code I'm using to try to customise the cell:
((HPReorderTableView *)self.tableView).reorderDragView.layer.shadowColor = UIColorFromRGB(0x89BAE9).CGColor;
((HPReorderTableView *)self.tableView).reorderDragView.backgroundColor = [UIColor clearColor];
[((HPReorderTableView *)self.tableView)registerTemporaryEmptyCellClass:SCSpotCell.class];
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorColor = [UIColor colorWithWhite:1 alpha:0.2];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, self.bottomLayoutGuide.length, 0);
Thanks
Emilio
I'm not sure how to deal with this. I've determined that tableView:titleForFooterInSection:
and tableView:titleForHeaderInSection:
don't work on my data source, when I'm using HPReorderTableView.
Am I doing something wrong?
I have a question, now that I am using HPReorderTableView the swipe to show the Delete Button no longer works.
Is there a way to enable it again? I already tried below.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//NSLog(@"FIRST_DELETE");
NSFetchedResultsController *frc = [self frcFromTV:tableView];
List *deleteTarget = [frc objectAtIndexPath:indexPath];
[frc.managedObjectContext deleteObject:deleteTarget];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}
Thank you
This works well - nicely done! The only issue I'm having is that before the reorder, my cells have an animation going, on endless loop. I don't mind the fact that while dragging, the content is replaced by a static screenshot UIImage of the cell (that actually feels intuitive for the user) but after the drop in the new location, the static screenshot is over the top of my actual cell and hence I can't see the animation. Am I doing something wrong or is there some way to remove the static image after the reorder?
I am running into an issue in the cellForRowAtIndexPath while dragging the row around eventually it crashes on the line below. Any thoughts?
Note: Since images are stored as external files in Core Data sometimes they take a few seconds to load. In order not to bug down the system I am using the dispatch_async. If I do not use the dispatch_async it does not crash
Crashes
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
cell.imageViewPhoto.image = nil;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSArray *listImagesArray = list.relationship_List_Images.allObjects;
NSArray *imagesNamesArray = [listImagesArray valueForKey:@"image"];
UIImage* thumbnail = [[UIImage imageWithData:[imagesNamesArray objectAtIndex:0]] fixToCorrectOrientation:160 compressionQuality:1.0]; //[UIImage imageWithData:[imagesNamesArray objectAtIndex:0]];
if (thumbnail) {
dispatch_async(dispatch_get_main_queue(), ^{
//return to the main thread to update the UI
if ([[self.tableView indexPathsForVisibleRows] containsObject:indexPath]) {
//check that the relevant data is still required
MasterViewControllerCell * correctCell = (MasterViewControllerCell *)[self.tableView cellForRowAtIndexPath:indexPath];
//get the correct cell (it might have changed)
correctCell.imageViewPhoto.image = thumbnail; // CRASHES HERE
}
});
}
cell.imageViewPhoto.hidden = NO;
});
....
Does not crash
NSArray *listImagesArray = list.relationship_List_Images.allObjects;
NSArray *imagesNamesArray = [listImagesArray valueForKey:@"image"];
cell.imageViewPhoto.image = [[UIImage imageWithData:[imagesNamesArray objectAtIndex:0]] fixToCorrectOrientation:160 compressionQuality:1.0]; //[UIImage imageWithData:[imagesNamesArray objectAtIndex:0]];
cell.imageViewPhoto.hidden = NO;
cell.labelNoteRightMarginContraint.constant = 100;
Thank you.
Hi, thanks for the nice library.
However, the pop up animation differs every time I long press each tableview cell, sometimes it pops to the upper side, sometimes it pops to the below.
Is there any way to show only one pop animation after long pressing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.