只是 UIPickerView 中的数字?
有没有办法让 UIPickerView 将数字递增到无穷大? 哈哈。开玩笑,但说真的,我只想要一堆数字上升,但我不想全部硬编码。
提前致谢!
Is there a way to have a UIPickerView just have escalating numbers to infinity?
Haha. Just kidding, but seriously, I want just a bunch of numbers going up, but I don't want to have to hard-code it all.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我很确定这可以通过一些技巧来完成(一个自定义整数类,支持任意大的数字,并且一旦用户滚动所有 NSIntegerMax 行(即当用户滚动时)定期“滚动”到更高的数字集要行 NSIntegerMax,您以编程方式将它们滚动回第 0 行并显示“row + NSIntegerMax”,而不仅仅是“row”)。当它们重复滚动时,您将其更改为“row + NSIntegerMax * 2”等。
显然,您还必须这样做 但我怀疑这比你想要做的更花哨
,在这种情况下,你只想将这些代码行添加到你的视图控制器中:
然后双击视图 nib 文件( *.xib 文件)以在 Interface Builder 中打开它,并将“数据源”出口连接到“文件所有者”(视图控制器),这将为您提供我能想象到的尽可能多的整数。
I'm pretty sure this can be done with some cleverness (a custom integer class that supports arbitrarily large numbers, and periodically "rolling over" to a higher set of numbers once the user has scrolled through all NSIntegerMax rows (i.e. when the user scrolls to row NSIntegerMax you programmatically scroll them back to row 0 and display "row + NSIntegerMax" instead of just "row"). As they scroll through repeatedly you change it to "row + NSIntegerMax * 2", etc.
Obviously you also have to handle them changing directions are some point.
But I suspect that's what fancier than what you're looking to do. In this case you just want to add these lines of code to your View Controller:
Then double click on the View nib file (the *.xib file) to open it in Interface Builder, and connect the "data source" outlet to the "File Owner" (the View Controller). That will get you as many integers as I could ever imagine someone scrolling to.
看看这个问题。这是你的问题的一个变体。
Have a look at this question. It is a variation on your problem.
你可以只使用 UIStepper。我知道你问过 UIPicker 但你真的需要使用那个类还是你用它来解释你想要什么样的东西
You could just use a UIStepper. I know you asked about UIPicker but do you really need to use that class or were you using it to explain what kind of thing you wanted