小编Yas*_*med的帖子

应用 UITableViewDiffableDataSource 快照后 TableView 滚动到顶部

我正在使用 UITableViewDataSourcePrefetching 进行分页。

这些值将从领域本地存储中获取。

我将得到一个对象数组。这些值将应用于现有的 UITableViewDiffableDataSource 数据源。

应用快照后,表格视图滚动到顶部。

我已经验证我的所有 ChatMessage 对象都具有唯一的 hashValues。

如何防止滚动?

视频链接TableView_scroll_issue_video

鉴于我的代码片段

private func appendLocal(chats chatMessages: [ChatMessage]) {
    var sections: [String] = chatMessages.map({ $0.chatDateTime.toString() })
    sections.removeDuplicates()
    guard !sections.isEmpty else { return }
    var snapshot = dataSource.snapshot()
    let chatSections = snapshot.sectionIdentifiers
    sections.forEach { section in
        let messages = chatMessages.filter({ $0.chatDateTime.toString() == section })
        /// Checking the section is already exists in the dataSource
        if let index = chatSections.firstIndex(of: section) {
            let indexPath = IndexPath(row: 0, section: index) …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift diffabledatasource uitableviewdiffabledatasource

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

如何在swift中剪切uiview的边缘

在此输入图像描述

我附上了查看图片.我想在购买按钮和上面的航班信息视图之间实现底部的小切.

uiview cashapelayer swift

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

如何在另一个单元格的视图中加载一个单元格?

它是我的内心细胞

上面的是我的内心细胞。我想将此单元格加载到下面的单元格中。内部单元的数量是动态的。 在此处输入图片说明

上面的是我的主要单元格。红色部分是UIView。我想将一些innerCell动态地添加到UIView中。我尝试了以下代码

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let mainCell = tableView.dequeueReusableCell(withIdentifier: "FlightCellMain", for: indexPath) as? FlightCellMain
    let innerCell = tableView.dequeueReusableCell(withIdentifier: "FlightCell", for: indexPath) as? FlightCell


    mainCell?.flightCellView.addSubview(innerCell!)
    mainCell?.backgroundColor = .clear
    innerCell?.backgroundColor = .clear
   // innerCell?.innerCellWidthConst.constant = (mainCell?.mainView.frame.width)!
    self.showStopsView(2, self.airportlist, (innerCell?.leftRound)!, (innerCell?.rightRound)!, (innerCell?.centerLine)!, (innerCell?.routeView)!)
    mainCell?.flightCellViewHieghtConst.constant = (mainCell?.flightCellViewHieghtConst.constant)! + 125
    innerCell?.layoutIfNeeded()
    mainCell?.layoutIfNeeded()
    return mainCell!
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

但是结果就是这样。我提供了自动布局。当我分别运行两个单元格时,它适合其内容。我在做什么错?

在此处输入图片说明

上面的图片是我试图实现的模型。航班数量详细信息是动态的。

uitableview uiview ios swift

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