久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

UITableView 狀態(tài)持久化中的復選框

Checkboxes in UITableView State Persistence(UITableView 狀態(tài)持久化中的復選框)
本文介紹了UITableView 狀態(tài)持久化中的復選框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

所以我有一個包含選項單元格的表格,每個單元格都有一個綁定標簽和 BEMCheckbox 庫提供的復選框.一切正常,但是,當我選擇前三個選項并向下滾動時,我發(fā)現(xiàn)選擇了其他三個相鄰的單元格,即使我還沒有遇到它們.

So I have a table which contains option cells, each of which has a bound label and check box provided by the BEMCheckbox library. Everything works fine, however, when I select let's say the first three options and scroll down, I find three other adjacent cells selected even though I have yet to encounter them.

我知道這與 UITableView 的內(nèi)部工作原理以及單元格在滾動時基本上如何重用和重新渲染有關,但我沒有嘗試保持狀態(tài)似乎有效.目前我正在嘗試將選定的 IndexPath 對象存儲在一個數(shù)組中,并且在 cellForRowAt 中,我將繪制復選框,就像路徑出現(xiàn)在數(shù)組中一樣.但是,即使這樣似乎也不起作用.任何想法如何解決它?

I understand this has something to do with the inner workings of UITableView and how cells are basically reused and re-rendered as they are scrolled, but no attempt I make to persist state seems to be working. At the moment I'm trying to store selected IndexPath objects in an array, and in the cellForRowAt I will draw the checkbox as on if the path appears in the array. However, even this doesn't seem to work. Any ideas how to fix it?

推薦答案

將表格視圖單元視為您在醫(yī)生辦公室候診室獲得的患者信息表格.問題是醫(yī)生辦公室會重復使用這些表格,并且不會刪除其中的舊信息.

Think of a table view cell as the patient info form you get in the waiting room at a doctor's office. The catch is that the doctor's office reuses the forms, and doesn't erase the old info from them.

在您的 cellForRowAt 方法中,您可以在再次使用之前完全將單元格恢復到其默認狀態(tài).您必須將所有內(nèi)容重置為默認狀態(tài).

In your cellForRowAt method, it's up to you to completely restore the cell to its default state before using it again. You have to reset everything to it's default state.

作為在 cellForRowAt 中進行重置的替代方法,您可以使用自定義單元格并實現(xiàn) prepareForReuse() 方法.

As an alternative to doing that resetting in cellForRowAt, you can use a custom cell and implement the prepareForReuse() method.

關鍵是在開始配置之前,您需要將單元格中的每個視圖強制設為默認狀態(tài).

The key thing is that you need to force every view in the cell to it's default state before you begin configuring it.

這篇關于UITableView 狀態(tài)持久化中的復選框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內(nèi)容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
Make background color change during scroll(在滾動期間更改背景顏色)
UITextView text cut off when there is a large amount of text(文本量大時UITextView文本被截斷)
主站蜘蛛池模板: av在线视| 久久久久久国产精品免费免费 | 色婷婷精品国产一区二区三区 | 日韩成人一区 | 欧美二三区 | 特级生活片 | 麻豆精品国产91久久久久久 | 日韩在线观看一区 | 亚洲精品在线免费观看视频 | 97热在线 | 一区二区三区在线免费观看 | 观看av | 午夜视频导航 | 午夜成人免费视频 | 欧美性成人 | 免费一级欧美在线观看视频 | 九九在线视频 | 久久久精品影院 | 国产探花在线精品一区二区 | 欧美一级大片 | 成人精品 | 亚洲精品视频在线观看免费 | 精品国产一区探花在线观看 | 综合一区二区三区 | 国产精品久久久久久久久久免费看 | 久久国产精品首页 | 亚洲精彩视频在线观看 | 日韩精品成人 | 亚洲一区久久 | 粉嫩一区二区三区四区公司1 | 欧美精品久久 | av网站在线免费观看 | 91视频88av | 99久久99| 国产精品久久久 | 色婷婷在线视频 | 一区二区在线 | av国产在线观看 | 91久久精品国产免费一区 | 国产精品久久久久久中文字 | 国产精品福利网站 |