reuseidentifier

UITableViewCell reusability issue. Modifying one cell is affecting others

一笑奈何 提交于 2020-01-17 06:38:10
问题 Whenever a cell from section 3 is selected. I'm updating the DataSource array, and the cell's background color is thus changing correctly. However, whenever I scroll back up I start seeing random cells with the modified background color, knowing that I don't even mention it in my cellForRowAtIndexPath method and each section in my tableView is populated from a separate DataSource Array/Dictionary ! (I'm using a Storyboard to handle all UI setup) Here's my code (focus on Section 3) -

UITableView and Cell Reuse

▼魔方 西西 提交于 2020-01-14 07:57:21
问题 I have a UITableView and I've subclassed UITableViewCell (called it CustomCell ) so it has several labels and a UIImageView . Only certain cells will actually display an image. Here's my code for tableView:cellForRowAtIndexPath: : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Match *aMatch = [[appDelegate.matchByDate objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; CustomCell

UITableView separators drawn incorrectly through cell reuse?

我只是一个虾纸丫 提交于 2020-01-13 09:15:42
问题 I'm working on an iOS 5 project with storyboards, and thus using dynamic table cell prototypes in IB. In one of the views, I've got a table view with variable-height cells, with the cell height calculated from the height of the contents. tableView:heightForRowAtIndexPath: returns correct values for all cells when the table view is first displayed. All is well when scrolling down for a few items, but then something goes amiss: the actual cells seem to be correct height, including their touch

dequeueReusableCellWithIdentifier:forIndexPath: VS dequeueReusableCellWithIdentifier:

孤人 提交于 2020-01-11 02:28:45
问题 I have read this question and think that I understand the difference between the two methods until I find a strange example: Set table view cell's style be Basic , Identifier be Cell in Storyboard, code as below: import UIKit class TableViewController: UITableViewController { var items: [String]! override func viewDidLoad() { super.viewDidLoad() items = ["first", "second", "third"] } override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } override func tableView

CollectionView, TableView registered classes for reuse identifiers

笑着哭i 提交于 2020-01-06 05:03:51
问题 I want to know which classes are registered with a UITableView or a UICollectionView with reuse identifiers is it possible to find this info? I've checked the class references and didn't find anything. I wanted to unregister certain classes from the tableview in order to replace them with other classes. I know i can just change the reuse identifier, however, I'd like to know if there is a way to get the registered classes/nibs of these objects 回答1: It seems to be reuse identifier is married

CollectionView, TableView registered classes for reuse identifiers

ぐ巨炮叔叔 提交于 2020-01-06 05:03:09
问题 I want to know which classes are registered with a UITableView or a UICollectionView with reuse identifiers is it possible to find this info? I've checked the class references and didn't find anything. I wanted to unregister certain classes from the tableview in order to replace them with other classes. I know i can just change the reuse identifier, however, I'd like to know if there is a way to get the registered classes/nibs of these objects 回答1: It seems to be reuse identifier is married

iOS: UITableView mixes up data when scrolling too fast

孤街浪徒 提交于 2019-12-23 13:11:15
问题 I've subclassed the UITableViewCell to add custom appearance to it. At the init level of the MYTableViewCell I added 4 subviews: UIImageView, and three UILabel(s). All 4 subviews have a different Tag assigned to them. Inside the cellForRowAtIndexPath method I either create a new cell if it wasn't available at first, or reuse available one and assign the proper text to the ui labels. The problem I am having is that if I try to scroll super fast, then the data gets messed up, however if I

dequeueReusableCellWithIdentifier:forIndexPath: VS dequeueReusableCellWithIdentifier:

好久不见. 提交于 2019-11-30 20:33:48
I have read this question and think that I understand the difference between the two methods until I find a strange example: Set table view cell's style be Basic , Identifier be Cell in Storyboard, code as below: import UIKit class TableViewController: UITableViewController { var items: [String]! override func viewDidLoad() { super.viewDidLoad() items = ["first", "second", "third"] } override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return items.count } override func

How to purge a cached UITableViewCell

让人想犯罪 __ 提交于 2019-11-30 20:08:26
Does anyone have suggestions on how to purge a cached UITableViewCell ? I'd like to cache these cells with reuseIdentifier. However, there are times when I need to delete or modify some of the table rows. I expect to call reloadData after the row changes. Right now, dequeueReusableCellWithIdentifier always returns the cached(obsolete) entry from before. How do I indicate that the cache is stale and needs to be purged? I'm not sure why you're trying to purge cells in the first place. Every time you dequeue a cell, you need to re-set any data that needs to be displayed. The caching just prevents

How to purge a cached UITableViewCell

試著忘記壹切 提交于 2019-11-30 04:38:32
问题 Does anyone have suggestions on how to purge a cached UITableViewCell ? I'd like to cache these cells with reuseIdentifier. However, there are times when I need to delete or modify some of the table rows. I expect to call reloadData after the row changes. Right now, dequeueReusableCellWithIdentifier always returns the cached(obsolete) entry from before. How do I indicate that the cache is stale and needs to be purged? 回答1: I'm not sure why you're trying to purge cells in the first place.