小编Zhe*_*i.C的帖子

保留嵌套 collectionView 的滚动位置

之后,tableView.reloadData()可见collectionView显示的第一行意外马上。

我在其单元格中构建了一个tableView包含collectionView,用户可以tableView像 Instagram 一样在每一个中滚动多个图像。我该如何解决?谢谢!

表视图数据源

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return photoRolls.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as! HomeTableViewCell
    if photoRolls.isEmpty {
        return UITableViewCell()
    }        
    let user: UserModel = users[indexPath.row]
    let photoRoll: PhotoRoll = photoRolls[indexPath.row] //this Model contains post info: likes, comments etc.
    let photoUrls: UrlStrings = urls[indexPath.row] //this Model contains a …
Run Code Online (Sandbox Code Playgroud)

uitableview collectionview ios swift

3
推荐指数
1
解决办法
1077
查看次数

标签 统计

collectionview ×1

ios ×1

swift ×1

uitableview ×1