Animating cells while UITableView is scrolling - objective-c

I'm trying to achieve an effect wherein as a tableview is scrolling, the currently visible cells will animate according to where they are positioned on the screen. I'm somewhat new to IOS dev, so let me try to break it down:
Tableview loads with custom cells User begins scrolling While the
table is in motion, the visible cells have a UIView in which I would
like to perform an animation that corresponds directly to the cell's
current Y position on the screen.
Cells will ONLY animate when they
are visible
Cell animation directly corresponds to table motion, i.e.
whenever the table view scrolls, the cells are animating; once the
table stops, the animations pause
One solution I have thought of is to update drawRect every single frame when the tableview is moving. Depending on the graphic operations, this could be horrible performance wise. Is there a way to grab the current table position every time it changes? Would I be better suited to use Core Animation?

This might be helpful if you want to achieve something like below:
https://github.com/mrugrajsinh/AnimatedTableViewCellDemo

Make your view controllers the delegate of the UITableView, and use all the methods of scrollview Delegate also. There you have many controls for start scrolling and end scrolling, and within thpse controls you could check for uitableview cell positioning.

You have to become delegate to this: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html
and this is the method to override and animate your cells:
– tableView:willDisplayCell:forRowAtIndexPath:

Related

Select CollectionViewCell when scrolled into view

I have a collection view that is 100 points wide with a number of cells that are each also 100 points wide. I've got it setup to support scrolling and paging horizontally so the user can flick left and right and each cell occupies the entire collection view frame.
Originally, I had no scrolling and the user would tap each cell to activate something in the app. Now that its a narrow frame where only one cell can be seen at a time I feel that tapping is redundant and the cell should simply be tapped in effect when it comes in view.
Is there a way to trigger an event such as didSelectItemAtIndexPath when a given UICollectionViewCell becomes the one displayed within my collection view's frame?
UICollectionView responds to selectItemAtIndexPath:animated:scrollPosition:.
It also responds to indexPathsForVisibleItems which will be useful to determine where to make the selection.
You also need to decide when to make the selection, probably best after receiving scrollViewDidEndDecelerating: which the delegate inherits from UIScrollViewDelegate).
But it may be even better advice to look at what your code does upon selection and just do that (launched from the same place in code, probably when scrolling is finished), leaving selection out of it.

Retaining UICollectionViewCell while scrolling a UICollectionView

I'm trying to figure out a way to keep a UICollectionViewCell from being removed (didEndDisplayingCell) from my UICollectionView when its original scroll position scrolls off of the view. I know this is the way a UICollectionView is supposed to work, that cells are removed and returned to the reuse pool when they are no longer visible, but this is based on their original position in the UICollectionView. I'm trying to drag that cell past the original visible area into a further away location, but it gets removed killing the pan gesture in progress and killing its view in the collection view once its original position is scrolled out of view. Is there a way to override this behavior and hold onto a UICollectionViewCell until I'm done with it?
I've seen the other ways to attack this problem by creating an image of the cell and dragging that instead, but that won't satisfy my purposes. I need the original cell to survive beyond its original screen position as I scroll through the UICollectionView.
Make copy when dragging your cell around and hide original cell.

Background color in cells in NSTableView is 1 pixel off

I am making an OSX app, and for part of it, I am using NSTableView to simulate a "timeline", by putting in a really thin column and then setting the background color. It's fine, except for whatever reason the cell seems to be 1 pixel off whenever the background color changes. Anyone got any ideas? I don't have the reputation to post an image so here's the link: http://imgur.com/PrLdjIV
Thanks for reading this!
An NSTableCellView will not necessarily fill a row from edge to edge. Likewise, an NSTextField inside such a cell view will not necessarily fill it from edge to edge.
Implement -tableView:didAddRowView:forRow: in your table view delegate and set the row view's backgroundColor.

iOS table view having text fields scrolling issue

I have a UITableView which is composed of custom cells. There are 21 cells containing text fields.
When I try to scroll and edit the cells at the bottom of the UITableView, I can't manage to get my cells properly positioned above the keyboard.
Also i created a custom cell class separately for my cells. So keyboard delegates are available on that class only.
I have seen many answers talking about changing view sizes,etc... but none of them has worked nicely so far.
Could anybody clarify the "right" way to do this with a concrete code example?
There are three approaches to this problem all of which tie into the keyboard did / will show notification....
When the keyboard appears, you move the whole view (including tableview) up to ensure the selected textfield is shown on screen, you can calculate this by getting the keyboard height (from the notification) and the textfield position.
You can resize the tableview so that it is only as big as the portion of the screen not covered by the keyboard, again get the height from the notification.
You can set the content inset for the tableview (for the bottom value) to the height of the keyboard.
If you need to, when resizing or repositioning the tableview, you may need to set it to scroll the content to the rect of the text field to ensure it is in view...
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;

Animating rows in an NSTableView

Is there a simple way of animating rows in an NSTableView?
I'd like to be able to do something like flash a row, or fade out a row.
Essentially - to provide a bit of visual feedback when rows are added or removed.
Edited to add:
I'd had a quick look over Google before posting this; but I wanted to know if there was some way to do this that I'd missed other than drawing and animating parts of the table view myself.
To flash a row, there are a number of ways to go. You could just grab a cell and play with it's view, such as change the color of the background or font colors. You could also just select the cell and deselect it a few times, if you don't care about removing the existing selection from another cell. Or you could superimpose another view on top of the cell's view and use blend modes...
For animating the deletion, you could do the same as above, dimming the cell, or even move the view up and out, transform it so it shrinks down and move it over to a trash can and shrink it all the way down as it enters the trash. Then after the animation is done, you delete the row.