How to insert a new Row in bottom of the UITableView Swift

后端 未结 4 1351
傲寒
傲寒 2021-01-12 18:10

I use

func insertRowsAtIndexPaths(indexPaths: [NSIndexPath],
withRowAnimation animation: UITableViewRowAnimation)

method to insert a new Ro

4条回答
  •  情书的邮戳
    2021-01-12 19:02

    Thanks @raf for the suggestion:

    What you need to do then, is animate the whole UITableView in it's parent view up as you insert elements. If you're using autolayout, capture the Top constraint in a property, and change it's constant as you insert elements. Something like:

     topConstraint.constant = newValue
     UIView.animateWithDuration(0.5, animations: { 
      self.layoutIfNeeded() 
    })
    

提交回复
热议问题