在自定义选择器中重新加载数据

发布于 2024-11-10 14:51:10 字数 506 浏览 4 评论 0原文

我创建了一个自定义选取器,具有漂亮的 X 射线镜头发光效果,用于目标选择。它只是由两个具有相同内容偏移量的 UIScrollView 组成。当标签进入镜头下方时,它看起来会发光。无论如何,我需要动态更新数据,如果它是普通的表视图,我知道我只会使用 [tableView reloadData]。我有用于分配标签/ rowHeight 和其他一些可自定义功能的自定义委托方法。我只需要在按下开关后重新评估所有这些委托方法。有什么建议吗?谢谢!!

编辑:

我以为我脑子里放屁了,而且大部分都是这样。我可以在自定义选择器类中编写自己的“reloadData”函数。我唯一的问题是让选择器调用 titleForRow 委托方法的次数等于行数。我知道我的选择器可以在视图加载时第一次执行此操作。我真的需要在 reloadData 函数中使用 FOR 循环吗?或者我缺少什么?

在我的重新加载方法中,我想调用:

[[self delegate] titleForRow:(int) forPicker:self];

再次感谢!!

I created a custom Picker with a nice X-ray lens glow effect for the target selection. It is just made up of two UIScrollViews with the same content offset. When the label goes under the lens it appears to glow. Anyways, I need to dynamically update the data and if it were a normal table view I know I would just use [tableView reloadData]. I have custom delegate methods for assigning labels / rowHeight and some other customizable features. I just need all these delegate methods to be reevaluated after a switch is pressed. Any suggestions? Thanks!!

EDIT:

I thought I was having a brain fart, and for the most part was. I can write my own "reloadData" function in the custom picker class. My only problem is having the picker call the titleForRow delegate method the number of times equal to the number of rows. I know my picker can do it the first time when the view loads. Do I really need to use a FOR loop in my reloadData function or is there something I am missing?

In my reload method I want to call:

[[self delegate] titleForRow:(int) forPicker:self];

Thanks Again!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪少女 2024-11-17 14:51:10

我一直在寻找一个快速修复方法..但确实正确的方法是在我的类的自定义重新加载函数中使用 FOR 循环。重新加载代码本质上与初始化代码相同,只是删除子视图并重新填充。

I was looking for a quick fix.. but sure enough the right way to do this was to use a FOR loop in a custom reload function for my class. The reload code is essentially the same as the initialization code, just removing subviews and repopulating.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文