Drag UITableView or all TableViewCells to display a label - swift

I'd like to create make a table view go to left when we swipe with a pan gesture. The goal is to display a label a the right of the table view like Instagram or iMessage for instance. Does anyone have a tip for creating this?
The result I would like to get.
https://i.stack.imgur.com/kDdSa.jpg

As a rough sketch, you may place a subview containing a timestamp inside your cell, below or to the side of the main subviews that display the content. You also will need to write a method that, depending on the pan progression, will show/hide this timestamp. Then you add a pan gesture recognizer to the table view itself, and, once panning, in your handler method you can call this disclosure method on the visible cells.

Related

Creating a dynamic add button swift

How would I be able to create a button that works similarly to the add phone button in the contacts app? As shown below, to replicate it, I have a button on the right side that the type is Add Contact (appears as a plus in a circle) and on the right is a label. I then put them together in a stack view.
How does the contacts app have one large (bar) button that holds the image and the text? When tapping on the button (in the contacts app) it highlights the whole bar. This makes me believe that might have done this using a UITableView.
What's the best way to create a similar (bar) button as they did? Would this be easier to replicate if I used a UITableView instead?
It's definitely a tableView.
They either constrained button's top to an empty tableView's bottom or they made this as an integral tableView and each time you didSelectRowAt it inserts a row at known position.
Suppose they either use a DataSource delegate method for rows insertion or a custom-made function wrapped in tableView.beginUpdates() and tableView.endUpdates() (reloads the table with animation)
you should not use stackview to wrap both button and right text.because you also need tap event.and stack view not giving tapping event.
I think you should place your button and label inside UIView and than Assing UIControl as Class in Inspecter(not UIView).than Controll drag from Your View to Class File and select TouchUPinside event.disabel user interaction of both button and Label otherwise event will not Fired.
and than Add above UIControll and other Component to either tableView or Vertical StackView.

drag and drop from uitableviewcell to uiimage view in ios

I need help implementing a drag and drop gesture, I would like to know Your opinion to find the best approach.
I have a view controller with a uitableview on the right and some image views on the left.
I would like to allow the user to drag every cell of the table view on one of the image views. Basically the drag-n-drop will fail if the cell is not released on one of the image views, otherwise the image view will change image according to the dropped cell.
What do You think is the best way to achieve this?
In addition, when the user start dragging, I would like that he drags around a particular shaped subview, with image and data, not drag the semitransparent cell.
Thanks,
The basic steps for this would be:
Add a long press gesture recognizer to your table view (the whole view, not individual cells)
When the gesture begins, find which cell it is over (convert point, then user indexPathForRowAtPoint to get the cell)
Make a copy of that cell which will become the dragged view (take a snapshot, add it to a UIImageView and add that to your main view). Or you could make the view look however you want if you dont want it to look like the cell
make your original cell hidden so it looks like it is being dragged
On gesture changed, move teh position of this image view based on locationInView of the gesture)
On gesture ended, check to see if the cell is over an image (hitTest: for this) and do any animations or calculations you need.

How do I tell the difference between the user tapping my table view cell and the user tapping a subview contained within the cell?

One of my view controllers contains a UITableView with custom UITableViewCell's. My custom UITableView cell contains a UIImageView subview that represents a tappable icon. When the user taps anywhere on the custom cell, except the icon subview, I want my didSelectRowAtIndexPath method to be called like normal. But when my icon subview gets tapped, I want a different method to get called, but I can't figure out how to do this. Do I have capture the touch position in the touchesDidBegin method and manually check if the user tapped the icon? That just feels so hacky. Other, cleaner ideas?
Thanks so much for your wisdom!
Simply add a tapGestureRecognizer to the UIImageView in your cell

iPhone: How to Place a Scrollview Inside of Tableview Cell

I want to put a scroll view inside of the table view cell. I have a number of buttons in one cell of table view and I need to scroll that cell to show the appropriate button.
If you want to use a vertical scroll view then I wouldn't suggest you doing it because, as TechZen wrote, there will be a mess in this case.
If you want the inner scroll view to scroll horizontally then it might be achieved by 2 ways:
Implement a custom table view cell that will include a scroll view inside it.
Add a scroll view as a sub-view to your cell that you will return from tableView:cellForRowAtIndexPath: method.
I suggest you to use the second approach.
There are plenty of examples online. Usually the sub-views are labels or image views, but it is not complicated at all to add a scroll view instead...
I don't think you can do this. It would require nesting of scrollviews which isn't really supported.
Even if it was, it would be very difficult for a user to know which scrollview they were hitting with their pudgy finger. Remember, you don't have the one pixel precision of a mouse on the iPhone. You have an area of at least 15x15 pixels. You don't have a scroll bar but instead just drags anywhere on the screen.
Instead, you should use a master-detail pattern. Selecting the cell in the tableview pushes a detail view which has the scroll view with all the buttons.
Why do you want to do it like this?
I think the best idea is to draw your table view manually above your uiscrollview. I did it, and it works. It just takes more effort and drawing accuracy. But that takes a lot of time. :)

How do you drag-and-drop from a TableView's icon to a stationary icon?

How do we go about coding drag-and-drop (or tap-and-drag) from a cell in a TableView on an iPhone? I'd like to have a set of drop destination icons that are stationary. I've been trying touchesBegan, touchesMoved and touchedEnded methods. These events fire nicely from a View so I can get a swipe to work nicely. Most likely the destination icons will be in a View so I think we are trying to get the drag-and-drop to begin in a TableView cell and end on an icon on a View that is beside the TableView.
Are you trying to drag the entire UITableViewCell, or a UIView inside the cell? Either way, I don't think you'll be able to move the view outside the bounds of its parent, which would be the UITableView.
I have another project where I have a icon or tile (UIImageView) that the user can drag around the screen. After it reaches a certain distance, it snaps back.
Similarly, a possible solution might involve popping up a UIView (perhaps a UIImageView) over top of the table cell when the cell is tapped. The user could drag that around the screen, and you could make it disappear when it's "dropped" on whatever target you have.