How to slide UITableViewCell in iOS - ios

I need to implement UITableViewCell what will move itself to right when user tap on it and then slide its finger to right. I need also to track a distance what cell has been moved. Is there any way to do something like this?

You need to use a scrollview. Implementing the delegate of that scrollview (in the cell itself or the view controller), you will know exactly how much the user has scrolled.
Here is an open source control which implements a similar functionality:
https://github.com/CEWendel/SWTableViewCell
Perhaps it will be of assistance to you.

Related

Move a button from one UITableViewCell to another with animation in Swift

I have a button and I want to keep track of which cell has the button with firebase. I can do this by putting the button in all cells and just make it visible in the one cell using firebase data. The part I'm stuck on is animating the button to move from one cell to another.
The only way I can think of is to put a delay on moving it from one to another, then have a separate animation happen. Then I think if I make the delay the same as the animation's duration then it will look like it just moved. I just thought of that while typing this but let me know if there's an easier/better way please!
This is a pretty tough thing to do, and animations can sometimes be one of the most difficult parts of mobile development. You aren't super clear on what your animation should look like, but since UITableViewCells each have their own contentViews I don't think directly animating the button from one cell to another is possible.
The best method I could think is to:
1) Draw a button on the screen at the location of the button you want to move
2) Hide the real button underneath
3) Animate this fake button over the tableview to the spot of the new, real button
4) End the animation and show the real button.
But you might have to block user interaction with the tableview while this happens to prevent them from scrolling and screwing up the animation...

Animate TableView Cell to swipe left

I would like to make a simple animation in the first cell of a table view to indicate that the user can delete this cell!
I have already completed the delete feature of the cell, etc.
How is it possible to achieve this like a bounce animation?
Facebook has already done that if you go to the notifications for the very first time you go to that view.
1) You can take one view inside cell. Design it whatever way you like.
2) Set it frames like it want be visible on screen while designing.
3) To adding animation effect, you can use default UIView animation or you can refer UIKit dynamics to achieve spring and bouns effect.
4) Set view frames progamatically to come from right to left.
4) Rest of the logic to display only one time, you can write it by yourselef :-)

iOS UI - App Store Explore section Transition

I was wondering if this nice master-detail transition where you click on the tableView cell and it expand to disclose the detail , with the cell's label being the navigation bar title is an interface which is part of the SDK object library or it is a customised one?
This is a custom transition between ViewControllers.
There's a nice example of a few transitions (including this one) in this library.
Of course you'll need to add the tableview etc' but this is a great place to start.
I've tried few things but so far this is the best option I could think of.
Animating the frames of all the visible cells and making use of childViewController is how I achieved it.
Animation test project
https://github.com/armaluca/iOS-App-Store-Explore-Section-Animation
Would be nice to know any other possible solution and ultimately to know how Apple did it!
It is custom implementation.There is no API in UIKit/UITableView which implements this behaviour. Only animation to present a cell is there(which I think is used here).
This behaviour can be implemented like-
Add sections(News, Productivity, etc) in table with zero cells(numberOfRowsInSection: = 0 for all sections). Then on tapping any section just reload that section(reloadSections:withRowAnimation:) by adding a cell to it(numberOfRowsInSection: = 1) and animation(maybe UITableViewRowAnimationMiddle). Scroll that section/row to top in same animation loop(UI update cycle).

Detect if a UICollectionViewCell is being displayed

I have set a UICollectionView to 'Paging Enabled'. I want to be informed when a UICollectionViewCell becomes active.
It seems like the collectionView:didSelectItemAtIndexPath: of the UICollectionViewController cannot achieve this effect: It only fires when a user explicitly select a cell, not when the cell is swiped to the front.
Each cell has a view controller associated with it. I probably can use viewDidLoad to as a proxy of this event. But it does not sound like a clean solution.
You can use collectionView:didEndDisplayingCell:forItemAtIndexPath: to detect that something changed and visibleCells to know what now on screen

How move/reorder cells from TableView1 to TableView2

I have several UITableViews, with different datasources in a iPad screen.
I need to copy/move a cell from the first tableView to the second, similar how is done with ListBox in other languages.
Now, I can reorder the cells, but the movement is restricted to the tableView. I want to drag the cell in tableView1 & drop in tableView2.
P.D. I'm open to use any other control to archive this. I take a look at AQGridView & DTGridView, however the layout is based in columns with different #items. If I can emulate columns with this controls or other then I can accept the workaround.
UPDATE:
I hope this links could help:
Observing pinch multi-touch gestures in a UITableView
This is the most close answer:
Drag and drop between two tables in ipad
I know how get a image from a view, I can detect the drag with a Gesture Recognizers, so I have all the setup in place but have not expertise in graphic development, so don't know how put this in motion...
This is definitely a very interesting question, and I wish I had the time to put together some test code to see if the idea I'm about to outline would actually work. My hope is that this will at least point you in the right direction.
UITableViewCell is a subclass of UIView, so I would create a subclass of UITableViewCell called something like DraggableTableViewCell so we can handle the touch events and then perform the following steps:
Create an instance of DraggableTableViewCell and configure it to appear like the selected cell.
Add the new cell as a subview of a view that is a common superview to both tables at the same location as the original cell.
Update the data source for the source table view and remove the original cell from the table view using deleteRowsAtIndexPaths:withRowAnimation:
Move the cell on the display by responding to touchesMoved:withEvent:
When touchesEnded:withEvent: is received, verify the cell is somewhat close to the other table view and determine the index path where to insert the new cell
Update the data source for the destination table view and call insertRowsAtIndexPaths:withRowAnimation:
Remove your draggable cell from its superview with a nice animation.
This entire process will need to be orchestrated by the view controller that controls the various table views on the screen.

Resources