相关疑难解决方法(0)

如何在表格视图中自动滚动?(迅速)

我在表格视图中添加了一个搜索栏,当用户搜索时,我希望表格视图滚动到您键入的文本.

如何使滚动视图自动滚动?

这是我尝试过的,但是我得到一个错误,说Integer不能转换为索引Path.我该怎么办?

self.tableview.scrollToRowAtIndexPath(1, atScrollPosition: UITableViewScrollPosition.Middle, animated: true)
Run Code Online (Sandbox Code Playgroud)

要么

self.tableview.scrollToNearestSelectedRowAtScrollPosition(scrollPosition: UITableViewScrollPosition.Middle, animated: true)
Run Code Online (Sandbox Code Playgroud)

search uitableview ios swift

18
推荐指数
3
解决办法
3万
查看次数

一直向下滚动到UITableView的底部

我有一个UITableView,我正在尝试加载36行,然后一直向下滚动到最后一个单元格.

我试过这个:

func reloadData(){
    chatroomTableView.reloadData()
    chatroomTableView.scrollToBottom(true)
}


extension UITableView {
    func scrollToBottom(animated: Bool = true) {
        let sections = self.numberOfSections
        let rows = self.numberOfRowsInSection(sections - 1)
        if (rows > 0){
            self.scrollToRowAtIndexPath(NSIndexPath(forRow: rows - 1, inSection: sections - 1), atScrollPosition: .Bottom, animated: true)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但它只会向下滚动一半.

uitableview ios swift

5
推荐指数
1
解决办法
8613
查看次数

标签 统计

ios ×2

swift ×2

uitableview ×2

search ×1