iOS (RubyMotion) Animated Cell Table Controller
This is a library that paves way for programmers to apply fancy animations on tapped cells. When a cell on a table is tapped, this library pops out the view of that cell. This view can be played around with as much as the imagination of the programmer lets him :). And there's more - there's a final means of wrapping it all up - placing the view back in its original slot! Check out the sample app to get a better picture. As always, hearty thanks to team lorempixel for their super awesome placeholder images.
Installation
Add this line to your application's Gemfile:
gem 'motion-animated-cell-table'
And then execute:
bundle
Or install it yourself as:
gem install motion-animated-cell-table
Sample App
A sample app is included for reference. To get it up and running, simply clone the repository and run rake
or rake device
depending on whether you want to preview it in the simulator or device.
Usage
There are a two things that you need to set up first:
- A table cell and its corresponding view (you can also use the default iOS cell)
- A duplicate view for the cell (the one that gets popped out)
The table cell needs to implement a special method called set_up_duplicate_cell_view
which accepts two parameters. The first is an instance of CGPoint
that gives the x,y position of the cell on the screen and the second is an instance of CGSize
that gives the dimensions of the cell. These two parameters can be used to construct the duplicate view and place it appropriately on the screen. Please refer to the sample app to get an exemplified version of this.
Let's call the table cell CustomCell
, its view CustomCellView
and the duplicate view DuplicateCustomCellView
. Now, here's how you can use the library:
-
Initialize the table view controller:
table = AnimatedCellTableViewController.new
-
There are very many attributes of the table you can set since it is ultimately a table view controller, but here are the are a few that need to be set mandatorily for the library - the delegate controller for the table, the height of the cells and the number of rows in the table:
table.delegate_controller = <DELEGATE_CONTROLLER>
table.height_of_cell = <HEIGHT_OF_INDIVIDUAL_CELL>
table.number_of_rows = <NUMBER_OF_ROWS_REQUIRED>
-
There are delegate methods for creating the individual cells and deciding what to do when a cell is tapped.
def cell_was_tapped index, duplicate_cell_view
end
def create_reusable_cell index, reusable_identifier
end
-
In addition to these fundamental methods, there are two more methods that can be used to show and hide the table:
table.show_table_view(duration)
table.hide_table_view(duration)
-
And there's more - an extra level of tweaking can be done using two more delegate methods. One is called after the show_table_view
animation is complete and one after the hide_table_view
animation is complete.
def after_show_table_view
end
def after_hide_table_view
end
Contributing
- Fork it ( http://github.com/multunus/motion-animated-cell-table/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request