Closed pbeneteau closed 7 years ago
Did u try setting hero id on collection view cell instead of imageview ??
Hi, yes I did, doesn't work. I noticed recently: there is a strange animation. in fact, there is an animation but it is ugly. As if the cell image get bigger (screen size) instantly and slide to the left. But this is not the growing/match animation of the demo.
You have to set isHeroEnabled
to the navigation controller if you are using one.
The same problem , can not find solution(
Same problem here, too many unreliable swift libraries wasting my time....
I found the solution, each cell in collection view should have own heroid; for example
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell",
for: indexPath)
cell.heroID = "cardNum" + String(indexPath.section) + String(indexPath.row)
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller: DayDetailViewController = storyboard.instantiateViewController(withIdentifier: "DayDetailViewControllerID") as! DayDetailViewController
controller.heroIdent = "cardNum" + String(indexPath.section) + String(indexPath.row)
self.present(controller, animated: true, completion: nil)
}
If every cell inside your collection view have the same heroId then it will not work. You have to set a unique heroId for each cell which match the heroId of the view that is presenting. For example: cell 1 might have "item-1" as heroId, and cell 2 might have "item-2". and depend on which cell you tapped on, you have to set the corresponding heroId to the view that you are presenting.
Got it working, in my case i needed to set isHeroEnabled on the UINavigationController. The first example code sets it on the UIViewController which is misleading.
It works almost as expected except there is a slight flash/fade of white when transitioning to the second controller. First controller is a grid of images and the second is larger image of the selected image so the resulting behavior should be a smooth zoom of the image.
Anyway thanks for the great library
Hi,
I have a
CollectionView
where I subclass the cells and I add an image in all the cells. I set the image hero id to "OGImage". I have aDetailViewController
where I have a background image with hero id "OGImage". I also setisHeroEnable
to true.Then, in the
didSelectItemAt
CollectionView protocol, I have:show(DetailController(), sender: Any.self)
When I click on the cell, there is no Hero animations but the default show animation.Hope I'm clear, thanks in advance for your help.