Ole*_*sun 5 uitableview ios swift
我用
func insertRowsAtIndexPaths(indexPaths: [NSIndexPath],
withRowAnimation animation: UITableViewRowAnimation)
Run Code Online (Sandbox Code Playgroud)
在表中插入新行的方法.但它出现在Top UITableView
(默认情况下).
我找不到任何从表格底部插入行的选项,比如屏幕截图:
我试过用UIEdgeInsetsMake
:
self.tableView.contentInset = UIEdgeInsetsMake(tableView.frame.height,0,0,0)
Run Code Online (Sandbox Code Playgroud)
但是当我滚动桌子时,它打破了所有的设计.
我的问题是:如何从表格底部插入新行?
UPD:当添加新行时,它应该看起来像从键盘视图移动到NavigationBar.
UPD2:这就是我想要的:http://recordit.co/JoR7xuvvpG
我是在帮助下做到的
self.tableView.contentInset = UIEdgeInsetsMake(tableView.frame.height,0,0,0)
Run Code Online (Sandbox Code Playgroud)
但是contentInset在行上方添加了一个大的白色字段,当我向下滚动时,隐藏了添加的行.看起来他们藏在keyboardView下面.我想阻止它.
Vim*_*din 18
斯威夫特3
TableView.beginUpdates()
let indexPath:IndexPath = IndexPath(row:(self.yourArray.count - 1), section:0)
TableView.insertRows(at: [indexPath], with: .left)
TableView.endUpdates()
TableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
Run Code Online (Sandbox Code Playgroud)
感谢@raf 的建议:
UITableView
然后,您需要做的是在插入元素时将其父视图中的整体动画化。如果您使用的是autolayout
,请捕获属性中的 Top 约束,并constant
在插入元素时更改它。就像是:
topConstraint.constant = newValue
UIView.animateWithDuration(0.5, animations: {
self.layoutIfNeeded()
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
21653 次 |
最近记录: |