Custom UITableViewRowAnimation or duration - objective-c

I have an app where the user can drag UITableViewCells from one TableView to another. I do this by rendering a "dummy" cell on top of the UITableViewCell that the user touches, and disable the "real" cell. I then insert a new row in the destination UITableView, after I have animated the dummy cell, to the position where the new cell will be inserted. This works as i want it to. But the other way around, causes me a lot of issues.
When a cell from the destination UITableView I double tapped, the cell should animate back to the source UITableView where it initially was dragged from. The problem is that I cannot remove the cell from the destination UITableView fast enough.
I want it to disappear instantly, so that when I render a dummy cell on top of it, I won't see an 2 different animations of the same cell. (the one where the dummy cell moves to the source UITableView, and the one where the actual cell is removed from the destination UITableView).
A reloadData on the UITableView is not good enough, because I still want the remaining cells to pull together on the now empty space, with an animation.
So, can I somehow create a custom animation, or set the duration of UITableViewRowAnimation to zero? UITableViewRowAnimationNone does not do anything for me.
Oh, and it might be important to mention that the app is not going on App Store, so I don't care if iI have to do something that Apple will not approve of.

Related

MKMapView blocks main thread while used in UITableView

I have a basic UITableView that contains 20 cells, one of the cells is a MKMapView just dropped in as is without any custom code (not even setRegion:Animated), if I open the view at the first time and scroll down the table view (towards the map's cell), there is a noticeable hang happens for the app, and if I use setRegion:Animated (without dropping any pin) the hang gets longer. However, this block of the main thread disappears on later attempts to scroll towards the map's cell.
I can't use the MKSnapShotter because I want the user to interact with the map so an image won't satisfy the case.
the table view does not make any block on the main thread if the map does not exist.
how to avoid blocking the main thread while showing the map's cell for the first time ?
First make a tableView IB outlet if you haven't already done so. Create the cell in view did load using tableView.dequeueReusableCellWithIdentifier("mapCellIdentifier") and store that in an ivar. Then in the data source return the cell when the index path is the one you want so inside of cellForRowAtIndexPath do
if (indexPath.row == wantedRow) {
return mapCell
}
The mapCellIdentifier needs to be set in the cell you created in interface builder for the map. This is assuming you have dynamic cells.

scroll last Cell to top of UITableView

on my last cell is a dynamic textview. With bigger contentSize it will be stay on top of the tableview (to see it, while you fill it on keyboard), but if the textview and also the cell is going to be dynamically bigger: [tableview beginupdates] and [tableview endUpdates] will delete my contentSize. And after that it is scrolling it down to bottom of tableview.
Any ideas how to scroll the cell to the top, and create the cell also dynamically without changes on contentSize? maybe I'm thinking on the right way, ideas?
EDIT
Hmm..not any "correct" solution found...the best way for this purpose is to try set any new cells or sections below the textview to get this cell easy to top of the view. After this its easy to use it with beginUpdates and endUpdates. The cursor will be always in the textview, textview will be dynamically bigger also the cell, so the only easy way.
Another option is to set the uitableview as a subview of another scrollview (uitableview himself has one) to scroll up an down in the new scrollview.
Thanks for help.
From my experience, Text views in cells is a very tricky issue. I recommend just using the free Sensible TableView framework, which has text view cells available out of the box.

Make UITableView movable and selectable

I know there is an 'editing' property for UITableView which puts it into an editing mode (cells are movable and/or deletable), but how would make a UITableView both selectable in the normal way, and movable?
So if the user taps and holds, he can move the cell up and down.. but if he just taps, then the cell gets selected.
check out something https://github.com/shusta/ReorderingTableViewController
It's open source so you can check the implementation, but the basic idea (i'm assuming from when I've done this, the link above may be slightly different) is
Add a long press gesture recognizer to the table view
When long press is recognized, create a UIView which represents the cell you are dragging, and move cells from underneath it as it is dragged

UITableView :cellForRowAtIndexPath Continues being called

I have a UITableView Controller and a UITableView. I have everything set up using the delegates etc, and it populates fine. I notice a small bug however with the following method:
:cellForRowAtIndexPath
I am noticing that this method is continually called every time I scroll the table. Even after the table is populated, it continues to call. Basically, a cell moves out of view, when it comes back in view, it is calling it again. I had NSLog print out the cell contents within that method, which is how I know it continues to call.
Should that function not just call once per cell, to populate it, then be done?
Nope. That's called every time a cell is needed, and a cell is needed every time one is rendered.
UITableView is a very clever little critter. It literally keeps only the cells it's displaying, plus a cache of literally two or three more. When the time comes to scroll a cell on that wasn't on, it can be asked for a cell from the cache, and if there is one, it gets reused.
This way HUGE data sets can be displayed in a UITableView, because there really aren't a large number of cells in memory, only the ones on the screen and a small cache.
This is correct behavior. It has to do with the dequeueing of UITableViewCells. That is why cell reuse is important. This way there are ideally a finite, small amount built in memory that continually get reused.
Check out the docs for more info and code samples.

Position of UITableViewCell

I'm using a tableview to display a list of rows and when selected, I want additional controls to appear right below the cell, probably in another view which I will control.
So far, I've managed to get a reference to the selected cell by running through the visiblecells array in the tableview but the frame property always returns a y-coordinate of 0 no matter what scroll position the table is in.
How do I get the position of the cell relative to the window?
I think the best way to deal with table views is in their own terms. That is, if you want to position something new inside the table, put it in a cell. It sounds like you want to subclass UITableViewCell to make your controls, and go through the whole tableView beginUpdates - insertCells - endUpdates process to animate their appearance.