Nativescript IOS 13 ui-listview 组件未呈现

Nativescript IOS 13 ui-listview component not rendered

大家好,我在 IOS13 上遇到了 listview 组件的问题 我尝试更新到最新版本,但这不起作用

我直接在 node_modules 中通过修补 listview.ios.js 修复了它 就像这里的评论所建议的那样:

https://github.com/NativeScript/nativescript-ui-feedback/issues/1160#issuecomment-542039004

这工作正常,但有什么不同的补丁吗?

例如:

我尝试创建新文件 app-platform.ios.js

并将缺少的方法直接附加到列表视图,如:

const listview = require('nativescript-ui-listview');

listview.ListViewCell.prototype.systemLayoutSizeFittingSizeWithHorizontalFittingPriorityVerticalFittingPriority = function (targetSize, horizontalFittingPriority, verticalFittingPriority) {
    if (this.view && this.view.itemView && this.view.itemView.parent) {
        var owner = this.view.itemView.parent;
        owner._preparingCell = true;
        var dimensions = owner.layoutCell(this, undefined);
        owner._preparingCell = false;
        return CGSizeMake(view_1.layout.toDeviceIndependentPixels(dimensions.measuredWidth), view_1.layout.toDeviceIndependentPixels(dimensions.measuredHeight));
    }
    return targetSize;
};

但这会破坏我的应用程序,我无法调用未定义的方法:/

如果有人仍然需要这个,设法在你 main.js 路径列表视图中用这个解决它。

const application = require('application');


if (application.ios) {
    const view_1 = require("tns-core-modules/ui/core/view");
    const listView = require('nativescript-ui-listview');

    listView.ExtendedListViewCell.prototype.systemLayoutSizeFittingSizeWithHorizontalFittingPriorityVerticalFittingPriority = function (targetSize, horizontalFittingPriority, verticalFittingPriority) {
        if (this.view && this.view.itemView && this.view.itemView.parent) {
            var owner = this.view.itemView.parent;
            owner._preparingCell = true;
            var dimensions = owner.layoutCell(this, undefined);
            owner._preparingCell = false;
            return CGSizeMake(
                view_1.layout.toDeviceIndependentPixels(dimensions.measuredWidth),
                view_1.layout.toDeviceIndependentPixels(dimensions.measuredHeight)
            );
        }
        return targetSize;
    };
}