Search code examples
nativescriptangular2-nativescriptnativescript-telerik-uinativescript-plugin

Nativescript IOS 13 ui-listview component not rendered


Hi guys I'm having problem with listview component on IOS13 I tried updating to the latest version but that doesn't work

I fixed it by patching listview.ios.js, directly in node_modules Like suggested from comment here:

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

And that is working fine but is there any to patch it differently ?

For example:

I tried creating new file app-platform.ios.js

and attaching missing methods to listview directly like:

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;
};

But that creashes my app, I get cannot call method on undefined :/


Solution

  • If someone still needs this, managed to solve it in you main.js path listview with this.

    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;
        };
    }