小编ate*_*kov的帖子

TableView willDisplayCell调用不在屏幕上的单元格(tableView分页)

我使用通过willDisplayCell(或cellForRowAt)进行自定义TableView分页的想法,并从服务器进行更新。

问题是,即使对于不在屏幕上的单元格,willDisplay也会调用。

仅当用户滚动到最后一个单元格时,如何处理此行为并更改流程以更新单元格?

private func isLoadingIndexPath(_ indexPath: IndexPath) -> Bool {
    return indexPath.row == self.orders.count - 1
}

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    // fetch new data if user scroll to the last cell
    guard isLoadingIndexPath(indexPath) else { return }
    if self.totalItems > orders.count {
        fetchNextPage()
    }
}

private func fetchNextPage() {
    self.currentPage += 1
    self.delegate?.didReachLastCell(page: currentPage)
}
Run Code Online (Sandbox Code Playgroud)

didReachLastCell调用addOrders:

func addOrders(_ orders: [OrderView]) {
    self.orders.append(contentsOf: orders)
    reloadOrders()
}

fileprivate func reloadOrders() …
Run Code Online (Sandbox Code Playgroud)

pagination uitableview ios swift

7
推荐指数
3
解决办法
5588
查看次数

如何像在 Measure 应用程序中一样在 ARKit (SceneKit) 中绘制虚线?

只是想知道是否有可能(我知道是,但如何)像在 Measure 应用程序中一样在 ARSCNView 中绘制虚线?也许有一种方法可以开箱即用地使用场景节点,idk。

我一直在使用 SCNCylinder 画一条直线,IDK 是否可以重复使用它并进行调整,或者我们必须使用一种非常不同的方式来制作虚线。

import SceneKit

class CylinderLineNode: SCNNode {

    private(set) var cylinder: SCNCylinder
    private(set) var positionA: SCNVector3
    private(set) var positionB: SCNVector3

    init(with positionA: SCNVector3, positionB: SCNVector3, radius: CGFloat = 0.02, color: UIColor = .red) {
        self.positionA = positionA
        self.positionB = positionB
        let vector = positionB - positionA
        let height = vector.length()
        cylinder = SCNCylinder(radius: radius, height: CGFloat(height))
        cylinder.radialSegmentCount = 8
        cylinder.firstMaterial?.diffuse.contents = color
        super.init()
        geometry = cylinder
        position = (positionB + positionA) / 2 …
Run Code Online (Sandbox Code Playgroud)

scenekit swift scnnode arkit

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

类型“{}”缺少类型“Request”中的以下属性:get、header、accepts、acceptsCharsets 以及其他 67 个属性

我正在离线模式下测试我的端点,模拟/伪造所有数据。基于云功能文档的Firebase单元测试,他们使用它如下:

const req = { query: {text: 'input'} };
const res = {
  redirect: (code, url) => {
    assert.equal(code, 303);
    assert.equal(url, 'new_ref');
    done();
  }
};

// Invoke addMessage with our fake request and response objects
myFunctions.addMessage(req, res);
Run Code Online (Sandbox Code Playgroud)

我的代码类似:

const req = {

}

const res = {

}

updateUser(req, res)

// and this is 'updateUser()' function in another file
export default functions.https.onRequest(async (req, res) => { ... }
Run Code Online (Sandbox Code Playgroud)

所以我收到以下错误:

“{}”类型的参数不可分配给“Request”类型的参数。类型“{}”缺少类型“Request”中的以下属性:get、header、accepts、acceptsCharsets 等 67 个属性。

如何避免将 67 个属性全部放入?我只想提供“方法”、“查询”或“主体”属性。

node.js express typescript google-cloud-functions

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