Reputation: 622
I am trying to add animations in tableview cells and the animations are working fine. But when i try to stop the scroll of tableview by tapping its not stopping. Usually in a scrolling tableview if we tap of screen the scroll would stop. But when i add these animations thats not working. below is the code i use for animations
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let rotationTransform = CATransform3DScale(CATransform3DIdentity, 0.4, 0.4, 0)
cell.layer.transform = rotationTransform
UIView.animateWithDuration(0.5) { () -> Void in
cell.layer.transform = CATransform3DIdentity
}
}
Upvotes: 6
Views: 1597
Reputation: 5602
Note:
This is normal behavior for animations using one of the animateWithDuration... method. Still if you want user interaction during the animation you can try like Below i have shown.
Simply you need to try like this :
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let rotationTransform = CATransform3DScale(CATransform3DIdentity, 0.4, 0.4, 0)
cell.layer.transform = rotationTransform
UIView.animateWithDuration(0.5, delay: 0.5, options: UIViewAnimationOptions.AllowUserInteraction, animations: { () -> Void in
cell.layer.transform = CATransform3DIdentity
}, completion: nil)
}
Hope it will help to you.
Upvotes: 8
Reputation: 57149
The main thing you’re hitting here is that UIView animations, by default, disable touches on the animating views while an animation is in progress. You can change that behavior by switching to the +animateWithDuration:options:delay:animations:completion:
method and adding the UIViewAnimationOptions value AllowUserInteraction
, like this:
UIView.animateWithDuration(0.5, delay:0, options:[.AllowUserInteraction], animations:{ () -> Void in
cell.layer.transform = CATransform3DIdentity
}, completion:nil)
Upvotes: 1
Reputation: 170
You could add a transparent UIView (the same size as the cell) above the animated views and once touched and/or when the animation is complete, remove the view from the subView.
Upvotes: -1