简体   繁体   English

UITableview部分问题

[英]UITableview section issue

I have a tableview with two sections. 我有两个部分的表视图。 I have loaded values from same array to the tableview. 我已将值从同一数组加载到tableview。 It is working fine, and I have customized the alpha value of the cell text in section 1, 1.0 and in section 2, 0.5. 它工作正常,我在第1节,1.0节和第2节,0.5节中自定义了单元格文本的alpha值。 When I scroll down the table it is working fine. 当我向下滚动表格时,它工作正常。 But when I scroll up (bottom to top), the alpha value of the section got changed to 0.5 (that is the value of section 1). 但是,当我向上滚动(从下到上)时,该部分的alpha值更改为0.5(即第1部分的值)。 Then the alpha value in both the sections are 0.5. 然后,两个部分的alpha值为0.5。 Why it is happening so? 为什么会这样呢? Does anybody know the solution, please let me know. 有人知道解决方案吗,请告诉我。

It is probably because you are reusing the cells, but not resetting the alpha values in the cell you are reusing. 可能是因为您正在重用单元格,但未在要重用的单元格中重置Alpha值。

If you have a line with 如果你有一条线

dequeueReusableCellWithIdentifier

in your cellForRowAtIndexPath method, then this is retrieving a cell for reuse - if you use this reused cell then you need to make sure you reset the alpha values of the background accordingly because it could be reused for a different row to the one the cell was originally created for. 在cellForRowAtIndexPath方法中,这是在检索要重用的单元格-如果使用此重用的单元格,则需要确保相应地重置背景的alpha值,因为它可以在另一行中重用为该单元格所在的行最初是为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM