UICollectionViewFlowLayout exception when executing XHR request in NativeScript

I tried to make a POST request for this API through Xcode 7. My error:

The behavior of the UICollectionViewFlowLayout is not defined because: the height of the element must be less than the height of the UICollectionView minus the upper and lower values ​​of the insert insert, minus the upper and lower values ​​of the insert content.

Corresponding instance of UICollectionViewFlowLayout: <_UIAlertControllerCollectionViewFlowLayout: 0x7f99fe411ea0> and it is attached to; layer =; contentOffset: {0, 0}; contentSize: {0, 0}> layout view: <_UIAlertControllerCollectionViewFlowLayout: 0x7f99fe411ea0>. Make a symbolic breakpoint in UICollectionViewFlowLayoutBreakForInvalidSizes to catch it in the debugger.

The code I tried to execute:

TypeScript:

makeRatingCall(userRating) {
    var score = userRating;
    var film_edition_id = "123456789";
    var computer_name = ConfigurationService.getUserData().user_username;
    var api_key = "key";
    return new Promise( function (resolve, reject) {
        let xhr = new XMLHttpRequest();
        xhr.open("POST", "my-url" + this.formatParams({film_edition_id, score, computer_name, api_key }), true);
        xhr.setRequestHeader("Accept", "application/json");
        xhr.onload = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                resolve(JSON.parse(xhr.responseText).err_code);
            } else {
                reject(xhr.responseText);
            }
        }
        xhr.onerror = function( err ) {
            reject ( err );
        }
        xhr.send();
    });
}

formatParams = function ( params ){
    return "?" + Object.keys(params).map((key) => {
        return `${key}=${encodeURIComponent(params[key])}`
    }).join("&")
}

rateIt() {
    var translate = this.translateService;
    this.makeRatingCall( this.currentRating )
        .then(function ( err_code ) {
            if (err_code == 0) {
                dialogs.alert({
                    title: translate.instant("VOTE_SUCCESSFUL"),
                    message: translate.instant("VOTE_SUCCESSFUL_MSG"),
                    okButtonText: translate.instant("OK")
                });
                this.rateInteraction = false;
            } else if (err_code == 1) {
                dialogs.alert({
                    title: translate.instant("ALREADY_VOTED"),
                    message: translate.instant("ALREADY_VOTED_MSG"),
                    okButtonText: translate.instant("OK")
                });
            } else {
                dialogs.alert({
                    title: translate.instant("VOTE_FAILED"),
                    message: translate.instant("VOTE_FAILED_MSG"),
                    okButtonText: translate.instant("OK")
                });
            }
        } )
        .catch(function ( err ) {
            dialogs.alert({
                title: translate.instant("VOTE_FAILED"),
                message: translate.instant("VOTE_FAILED_MSG"),
                okButtonText: translate.instant("OK")
            }); 

        });
}

HTML:

        <GridLayout columns="*4,*,*,*,*,*" rows="*">
            <Button col="0" row="0" [text]="'SEND_RATING'|translate" class="send-rating-button" (onTap)="rateIt()"
            [isUserInteractionEnabled]="rateInteraction"></Button>
            <Image src="{{ user_rating_imageurls[0] }}" col="1" row="0" class="star-image" (onTap)="rateFromUser('1')"
                [isUserInteractionEnabled]="rateInteraction"></Image>
            <Image src="{{ user_rating_imageurls[1] }}" col="2" row="0" class="star-image" (onTap)="rateFromUser('2')"
                [isUserInteractionEnabled]="rateInteraction"></Image>
            <Image src="{{ user_rating_imageurls[2] }}" col="3" row="0" class="star-image" (onTap)="rateFromUser('3')"
                [isUserInteractionEnabled]="rateInteraction"></Image>
            <Image src="{{ user_rating_imageurls[3] }}" col="4" row="0" class="star-image" (onTap)="rateFromUser('4')"
                [isUserInteractionEnabled]="rateInteraction"></Image>
            <Image src="{{ user_rating_imageurls[4] }}" col="5" row="0" class="star-image" (onTap)="rateFromUser('5')"
                [isUserInteractionEnabled]="rateInteraction"></Image>
        </GridLayout>

CSS

.send-rating-button {
    margin-top: 10;
    margin-left: 30;
    margin-right: 10;
    margin-bottom: 10;
    background-color: yellow;
}

.star-image {
    width: 30;
    margin: 10;
}

I'm not sure how to handle this error, does anyone have a clue for me ?: D

+6
source share
1 answer

It turns out I used appSettings.setNumber(...);in the module of application-settingsmy application. I changed it to appSettings.setString();and formatted the parameter to String, and now it has worked. Let's see if this is really a trick ...

+1
source

All Articles