Hero: Question: How to i animate only one item in a UITableView?

Created on 24 Feb 2017  路  4Comments  路  Source: HeroTransitions/Hero

I have a UITableView with many items in it.

When I tap on an item, only one gets animated unto the second viewController. All is well.
But
When I tap on the back button, because all the cells on the previous screen has the same heroID, all the cells gets animated when moving back.
Is there a way to only make one cell animate when i tap the back button?

Most helpful comment

@v-ken in the UITableView function

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

i set the heroID of each cell to be the indexPath.row number. This made each cell to have a unique heroID.

Then when i select the cell, i pass the hero ID to the new viewController.
So when i tab back to the previous controller, only one heroID will animate.
hope this helps

All 4 comments

Nevermind. Found the answer.
I can set the values in viewDidLoad.

@patchthecode Can you elaborate on how you solved this?
I assumed you set the heroID value of the destination view in its viewDidLoad?

Doesn't seem to be working for me.

@v-ken in the UITableView function

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

i set the heroID of each cell to be the indexPath.row number. This made each cell to have a unique heroID.

Then when i select the cell, i pass the hero ID to the new viewController.
So when i tab back to the previous controller, only one heroID will animate.
hope this helps

Ahh ok! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yoloabdo picture Yoloabdo  路  5Comments

cristinaITdeveloper picture cristinaITdeveloper  路  4Comments

BalestraPatrick picture BalestraPatrick  路  3Comments

josmanperez picture josmanperez  路  3Comments

pxwinter picture pxwinter  路  3Comments