首页 \ 问答 \ iOS上的Xamarin.Forms ListView上的最后一项无法访问(Last item on Xamarin.Forms ListView on iOS is not reachable)

iOS上的Xamarin.Forms ListView上的最后一项无法访问(Last item on Xamarin.Forms ListView on iOS is not reachable)

我有一个Xamarin.Forms应用程序 - 在iOS上一切正常,但我有一个ListView的问题。

当集合被更新时,ListView被更新,并且我可以看到新项目已经被添加到列表视图的顶部,但不知何故,当我到达时,视图中的最后一个项目将不再显示(!!!) ListView的结尾并尝试将ListView拉出来,我可以看到最后一项存在,但默认情况下不显示,并且无法访问,我无法打开它。

我试图重新绑定收集,做BeginRefresh和EndRefresh,但没有任何帮助。 任何人有这个问题? 或者我如何强制列表视图再次呈现?

这里是一个问题的例子,你可以在这里看到最后一项是“测试消息”。 (你可以看到框架不完整 - 底部的行没有显示)。 用户认为这是他拥有的最后一条消息: 在这里输入图像描述

虽然,如果我拉动ListView,我可以开始看到ListView中的最后一条消息:

在这里输入图像描述

但是,如果我的手指离开屏幕,则列表视图将返回以显示第一张图像,而最后两条消息已消失。

顺便说一句 - 这个问题只发生在我向ObservableCollection添加新消息时 - 同样如果我添加两个新消息,那么最后两个CellViews将不会显示,等等。 这个问题只发生在iOS上(在Android上它按预期工作)。

谢谢,赛义夫。


I have an Xamarin.Forms app - on iOS everything is working well but I have an issue with a ListView.

When the collection is updated, the ListView is updated and I can see that new item has been added to the top of the list view but somehow the last item in the view will no longer been shown(!!!) when I go down to the end of the ListView and try to pull the ListView up I can see that the last item is there but it is not shown by default, and it is not reachable I cannot open it.

I tried to rebind the collection again, to do BeginRefresh and EndRefresh but nothing helped. Anyone had this issue? Or how can I force the list view to render again?

Here is an example of the issue, you can see here that the last item is "Test message." (you can see that the frame is not complete - the line in the bottom is not shown). The user thinks that this is the last message he has: enter image description here

While, if I pull the ListView I can start seeing the last messages in the ListView:

enter image description here

But if I get my finger off the screen the list view will return to show the 1st image and the last two messages are gone.

BTW - this issue happen only when I add new message to the ObservableCollection - also if I add two new messages then the last two CellViews won't be shown and so on. This issue happens only on iOS (on Android it works as expected).

Thanks, Seif.


原文:https://stackoverflow.com/questions/40766638
更新时间:2021-12-19 11:12

最满意答案

你的代码有多个问题。 for循环格式不正确,需要用分号终止语句。 你也需要声明变量。 你的循环会运行numvalues + 1次,这就是为什么我在你的循环中删除了=的原因。 此外,如果你想计算一个平均你想除以numvalues。

function averageCalculator (numvalues) {
var result1 = 0;
for(i=0; i < numvalues; i++) {    
    var score = prompt("input the score");   
    result1 += score;    
}
alert(result1 / numvalues);
}

在无效语法的基础上,您将在这里遇到一个常见的“问题”。 输入被视为字符串,而不是被添加它们将被连接。 提供2和2作为分数将导致11.2与2 = 22/2 = 11连接。在将它们相加在一起之前,您需要明确地将该值转换为数字:

function averageCalculator (numvalues) {
var result1 = 0;
for(i=0; i < numvalues; i++) {    
    var score = prompt("input the score");   
    result1 += Number(score);    
}
alert(result1 / numvalues);
}

以上代码将正确返回2


Your code has multiple issues. The for loop is not well formatted and you need to terminate statements with a semi-colon. Also you need to declare variables. And your loop will run numvalues+1 times which is why i removed the = in your loop. Also if you want to calculate an average you want to divide by numvalues.

function averageCalculator (numvalues) {
var result1 = 0;
for(i=0; i < numvalues; i++) {    
    var score = prompt("input the score");   
    result1 += score;    
}
alert(result1 / numvalues);
}

On top of the invalid syntax you will run into a common "problem" with javascript here. The inputs are treated as strings and instead of being added they will be concatenated. Providing 2 and 2 as scores will result in 11. 2 concatenated with 2 = 22 / 2 = 11. You need to cast the value to a number explicitly before adding them together:

function averageCalculator (numvalues) {
var result1 = 0;
for(i=0; i < numvalues; i++) {    
    var score = prompt("input the score");   
    result1 += Number(score);    
}
alert(result1 / numvalues);
}

Above code will correctly return 2

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。