UIRefresh没有在视觉上重新加载整个表

时间:2016-04-06 13:27:04

标签: ios swift uitableview pull-to-refresh

我有一个UITableview,我可以刷新工作,清空所有数组,获取数据以填充它们,然后重新加载表。使用我的自定义动画,它看起来非常糟糕,因为整个表消失并重新生成。我希望它更新数据并添加一行或删除一个(如果需要)而不会闪烁整个表。 这是一个发生了什么的gif: https://giphy.com/gifs/8d4UlLrr2Qtlm

为表格单元格设置动画的代码:

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
     })

}

刷新控制的代码:

func refresh(sender: AnyObject)
{

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

    getData()  // gets server data

    tableView.reloadData()

    refreshControl?.endRefreshing()
}

0 个答案:

没有答案