Animating rows in an NSTableView - objective-c

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.

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.

Custom Background Image on Grouped UITableView

How would I go about setting a custom background image for a UITableView. The wrench in the works is that the table is a grouped style (rounded top corners for the first cell and rounded bottom corners for the last cell). I would like do this as much in code as possible without relying on images too much.
Ideally, here is the solution, but I have no idea if this will work or not:
Create one custom background image
Apply the same custom background image to every cell
Rounding occurs automatically because it is a Grouped table style
Profit.
Is this how it works (besides the profit part... I am an app developer, after all)? Do I need to re-think my approach or is this possible? How would do what I described (or another approach) in code specific to iOS 5+?
Update
Just to clarify a bit, the main question I'm asking is: Does the rounding still occur on the top and bottom cells even if you are using a rectangular image?
Well I think what you are saying is ok, but I suggest creating a unique cell layout in a .nib file and apply there the background. Then, with initWithNibName you can manage every cell at the UITableView's methods on the ViewController.

How to add empty cells in UITableView without expanding it

I have UITableView with custom looking cells. Now user can scroll past the bottom and see that there are no more rows (cells) and see background. I want to create impression that there are more rows below, but they should not be added to tableview, so when user scrolls down, it bounces back to last useful cell.
TableFooter and subview expands content and user can scroll there (or maybe I was doing it wrong).
Right now I added new empty cells and after any action that may recount contentSize I specifically set contentSize to default setting. But I feel like it's not the right way (although it works). Is there some other way?
I tried searching, but it's hard to explain what I want in few sentences, not to mention in search line.

Animating cells while UITableView is scrolling

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:

Transparent NSTableView

I want to customize my NSTableView. My overall requirements are like this:
Each row will have one image and some text; images and text could be different.
Some cells might not have an image.
Row height is dependent upon some external factor.
A cell shouldn't draw the background, it should show the NSTableView background.
So far I am able to draw transparent cells with some text. I Googled and found out I need to customize each cell. Now I have this question: should I maintain two columns or should one column be okay, having one image on the left hand side and text adjacent to that?
I also understand that I need to override two methods:
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
So for each cell, I need to draw/construct the cell -- can anyone guide me? Am I going in the right direction? Can I achieve a transparent background with dynamic height with the above approach?
Each row will have one image and some text,
So, two columns—one with an image cell, the other with a text field cell.
images and text could be different,
I should hope so.
Some cell might not have the Image,
Not a problem.
Row height is depend upon some external factor,
Be the table view's delegate, and it will ask you what the row's height should be.
Cell shouldn't draw the background,
It won't unless you set it to do so.
it should overall it should show the NSTableView background,
The table view will draw its own background anyway, which you can set in IB's Inspector. If you wanted the table view to not draw a background, you would set its background colors to the clear color.
You don't need a custom cell for any of this.