iphone 桌面视图滚动问题
我有一个表格视图,每个单元格中都有图像视图和文本视图。当我的视图加载时,其中一个文本视图是不可见的。但是当我开始滚动时,文本视图就会出现,以便我的视图看起来像它应该的样子。有谁知道为什么会发生这种情况? PS我已经读过有关滚动时重用单元格的内容,因此我非常小心地正确构建我的单元格。
I have a tableview with imageviews and textviews in each cell. When my view is loaded one of the textviews is invisible. But when I start scrolling the textview appears, so that my view looks as it is supposed to look. Does anyone know why this is happening?
P.S. I have read about reusing cells when scrolling so I have been very careful to construct my cells correctly.
没有代码,没有人能给你准确的答案。但猜测一下......
您的数据是否在表调用 cellForRowAtIndexPath 之后被填充?当单元格第一次填充时,没有数据,因此单元格处于未格式化状态。当您可以与表格交互并将其滚动到屏幕上时(再次调用 cellForRowAtIndexPath),数据已填充,因此单元格看起来符合预期。
您可以通过在 cellForRowAtIndexPath 方法中放置一个断点来测试这一点,并检查数据对象是否已初始化或仍设置为 nil。
Without code, no one can give you a exact answer. But for a guess....
Is your data is getting populated after your table call cellForRowAtIndexPath? When the cell populates the first time, no data, so the cell is in it's unformatted state. By the time you can interact with the table and scroll it off and on screen (which calls cellForRowAtIndexPath again), the data has been populated and so the cell looks as expected.
You can test this by putting a breakpoint in your cellForRowAtIndexPath method and check to see if your data objects are initialized or still set to nil.