gpt4 book ai didi

ios - 在 NativeScript 中执行 XHR-Request 时出现 UICollectionViewFlowLayout 异常

转载 作者:可可西里 更新时间:2023-11-01 03:58:46 27 4
gpt4 key购买 nike

我试图通过 Xcode 7 对给定的 API 执行 POST 请求。我的错误是:

the behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.

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

我尝试执行的代码:

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

我不确定如何处理这个错误,有没有人给我提示? :D

最佳答案

事实证明,我在应用程序的 application-settings 模块中使用了 appSettings.setNumber(...);。我将其更改为 appSettings.setString(); 并将参数格式化为字符串,现在它可以正常工作了。让我们看看这是否真的有用......

关于ios - 在 NativeScript 中执行 XHR-Request 时出现 UICollectionViewFlowLayout 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45914620/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com