shusta / reorderingtableviewcontroller Goto Github PK
View Code? Open in Web Editor NEWDrag and drop UITableView rows.
License: Other
Drag and drop UITableView rows.
License: Other
Hi, I check this project and I find it very interesting with a great animation fluidity. I have to create something similar but with drag and drop between tables inside the same viewController and between tables in different viewControllers. Do you think it´s possible to start from this project or even if that's a good idea?
Thanks
Hey,
First of all thanks for this neat drag-to-reorder addition!
But I've got some issues with it: Sometimes when I start dragging my TableViewCell will simply disappear (so the overlay that you use to still show it is not visible). When the user drags around, he will see an invisible spot moving.
Another thing that happens often is that when releasing the reordering, the cell released flashes for a split second between two different contents. So it shows the content of another cell, then switching back to its actual (and right) content.
Any idea on the cause?
I was unaware of contentInset when writing this and do not account for this in my code. This can cause the tableview to jump around or autoscrolling to be really weird.
ContentInset will be automatically set if a bar has UIBarStyleTranslucent.
Fix by taking contentInset into account when working with contentOffset
Can you please include a license file so that I can create a pod for this?
Thanks!
If you instantiate a UITableViewController that contains a ReorderingTableViewController and then reference its view (in my case in order to make it a subview of my root view), that reference instantiates the tableView. In doing so, the assertion in commonInit also references the view, but apparently before it gets created, so it gets created twice. Or something like that; it's very confusing.
The original symptom I was seeing is that the tableView's reordering gestureRecognizers were disappearing. Turned out that the tableView itself was getting replaced, but with no calls to viewDidLoad/Unload, so the logic for installing our gestureRecognizers failed. I tracked it down, finally, to the assertion.
Commenting out the assertion fixed the problem. If it's really necessary, I suppose it could be safely moved to viewDidLoad.
In ATSDragToReorderTableViewController.m, self got retained when blockSelf is accessed in block, thus self is never deallocated (ARC).
- (void)viewDidLoad {
[super viewDidLoad];
if ( reorderingEnabled )
[self establishGestures];
/*
* If app resigns active while we're dragging, safely complete the drag.
*/
__block ATSDragToReorderTableViewController *blockSelf = self; // self got retained when blockSelf is accessed in block, thus self is never deallocated (ARC)
resignActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification *arg1) {
if ( [blockSelf isDraggingCell] ) {
CGPoint currentPoint = [blockSelf->dragGesture translationInView:blockSelf.tableView];
[blockSelf fastCompleteGesturesWithTranslationPoint:currentPoint];
}
}];
}
I need to be able to show a table, but not as the whole of the screen.
I would usually do this by making a UIViewController, and sticking a UITableView within the nib, and linking the table to an IBOutlet property, and the delegates and datasource to the class.
@interface CustomViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *listTableView;
How would I do this with the ReorderingTableViewController?
I love what you have done so far, but I have a tableview that has sections and rows that I do not want a cell to move to. To solve this problem in the normal implementation of a UITableView move I would implement: - (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;
There doesn't seem to be any way to rule out index paths in your current implementation and I tried looking to see where I would do it but a lot of your code is beyond my experience with objective-c. Any pointers as to how I would implement this? Or perhaps you could implement it. But until then, unfortunately, I cannot use this beautiful implementation of moving rows.
Hello,
Thanks for adding a LICENSE so I can make a Podfile.
Would you mind also tagging the previous (non-arc) version as 1.0.0? This way, I can have two versions in CocoaPods available, one that's iOS 5.0+ and one that works with older versions. The command would be...
git tag -a v1.0.0 51e3113
Thanks!
Devin
It would be a convenience to add a delegate call just before the addDraggableIndicatorsToCell: animation block. Something like
dragTableViewController:willDragCell:forIndexPath:
in order to prepare the cell for the drag animation.
Use case: my table cells are borderless images, and the stock shadow tends not to be visible when the images are dark. So I've replaced the shadow effect with a slight enlargement of the cell, which works well. I need to composite an overlay imageview to do this right. I'd prefer to do the compositing in a willDrag call. (My workaround is to always composite the overlay for all cells, and control it with .hidden, which is of course not animatable, so I can get the effect I want by setting it to NO inside the animation block.)
According to your readme file, all I have to do to use this module is make my viewcontroller a subclass of ATSDragToReorderTableViewController rather than UITableViewController. My problem is that my viewcontroller currently looks like this:
@interface ViewController_iPad : UIViewController <GKSessionDelegate, UITableViewDelegate, UITableViewDataSource> {
.... other variables
UITableView *playersTableView;
... other variables
}
How should I use your code since i dont originally subclass UITableView? Sorry this may sound like a noob question, but I really need this to add some necessary functionality to my project.
Any feedback would be greatly appreciated.
Thanks
Any way to get this ported to a NSTableView?
Everything works fine as long as there are other cells in a section, but when you drag all cells away, there is no way to drag them back to the now empty section. Also sections that are empty from the start can't receive dragged cells. Is there a way to make this work?
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.