选择器行默认为倒数第二行
我有一个标准选择器(从文档中复制),有 6 行。行数正确记录为 6。当我尝试选择最后一行时:
[delpicker selectRow:5 inComponent:0 animated:NO];
它会选择第四行。但是当我尝试:
[delpicker selectRow:4 inComponent:0 animated:NO];
它选择正确的第四行(0 索引)。 事实上,它适用于第 0、1、2、3、4 行...只是不适用于第 5 行。当然,如果我要求第 6 行,它会将其设置为第一行(第 0 行)。
实际上,我希望选择器首先显示用户之前选择的行,并且我发现这对所有内容都适用,除非用户选择了最后一行。在试图找出原因时,我了解到即使只是像上面那样指定特定行也是行不通的。当用户选择最后一行时,该行被正确标记为最后一行(第 5 行)。问题只是在于设置 selectRow。
有什么想法吗?
I have a standard picker (copied out of the docs) with 6 rows. The row count is correctly logged as 6. When I try to select the last row:
[delpicker selectRow:5 inComponent:0 animated:NO];
it selects the 4th row instead. But when I try to:
[delpicker selectRow:4 inComponent:0 animated:NO];
it selects the correct, 4th, row (0 indexed).
As a matter of fact, it works fine for rows 0, 1, 2, 3, 4... just not for row 5. Of course, if I ask for row 6, it sets it to the first (0th) row.
Really, I want the picker start with showing the row that the user selected before, and I found that that works fine for everything unless the user selected the last row. While trying to figure out why, I learned that even just specifying a specific row, as I did above, is not working. When the user selects the last row, the row is correctly noted to be the last row (row 5). The problem is simply in setting the selectRow.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊。我为选择器指定的框架太大了!拾取器发生故障的原因真是愚蠢啊。
Ugh. The frame I'd specified for the picker was too big! What a silly reason for the picker to malfunction.