0

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 :/

5
  • Are you sure that your package.json reference "nativescript-ui-listview": "^7.1.0", or higher?
    – Tim
    Dec 16, 2019 at 13:14
  • yes, and it wont render item rows, but also my tns-ios is on 4.0.1 and tns cli is on 5.4.2
    – Loki
    Dec 16, 2019 at 13:31
  • What's the version of your tns-core-modules? Also whats the version of nativescript-ui-core in your package lock file?
    – Manoj
    Dec 16, 2019 at 14:04
  • Its not about the version if I edit directly listview.ios.js it is working, but how do I add those methods to prototype ?
    – Loki
    Dec 16, 2019 at 15:18
  • 1
    It's about the version, because those specific lines of code were fixed in 7.x I guess. There could be compatibility issues if you are running lower version of tns runtime / core modules with higher version of UI packages. But if you are fine with patching it up, you could but you should know how & where. I'm not sure where you found the above code but there are no reference of ListViewCell in the package. Here is a code snippet which seem to work for your case, with older version of list view.
    – Manoj
    Dec 17, 2019 at 11:41

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.