0

I have a UITableview and I have pull to refresh working where it empty all the arrays, gets the data to fill them ,and then reloads the table. With my custom animation, it looks really bad as the whole table disappears and reanimates in. I want it to update the data and add in a row or remove one if needed without flickering the entire table. Here is a gif of what happens: https://giphy.com/gifs/8d4UlLrr2Qtlm

Code to animate the table cell:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

     var cellContentView: UIView = cell.contentView
     var rotationAngleDegrees: CGFloat = -30
     var rotationAngleRadians: CGFloat = rotationAngleDegrees * (3.14159 / 180)
     var offsetPositioning: CGPoint = CGPointMake(500, -20.0)
     var transform: CATransform3D = CATransform3DIdentity
     transform = CATransform3DRotate(transform, rotationAngleRadians, -50.0, 0.0, 1.0)
     transform = CATransform3DTranslate(transform, offsetPositioning.x, offsetPositioning.y, -50.0)
     cellContentView.layer.transform = transform
     cellContentView.layer.opacity = 0.8
     UIView.animateWithDuration(0.65, delay: 0.0, usingSpringWithDamping: 0.85, initialSpringVelocity: 0.8, options: [], animations: {() -> Void in
     cellContentView.layer.transform = CATransform3DIdentity
     cellContentView.layer.opacity = 1
     }, completion: {(finished: Bool) -> Void in
     })

}

Code to refresh control:

func refresh(sender: AnyObject)
{

    nameArray = []
    textArray = []
    userArray = []
    latArray = []
    longArray = []
    timeArray = []
    locTextArray = []
    category = []
    eventID = []
    priceArray = []

    getData()  // gets server data

    tableView.reloadData()

    refreshControl?.endRefreshing()
}
user3015221
  • 125
  • 1
  • 6

0 Answers0