TableView reloadData vs. beginUpdates & endUpdates

From the UITableView documentation beginUpdates Begin a series of method calls that insert, delete, or select rows and sections of the receiver. That means, you should not use this unless you are inserting, deleting or selecting. You are doing neither of these. Also, you should end beginUpdates with endUpdates, not reloadData. Documentation: This group of … Read more

Iphone – when to calculate heightForRowAtIndexPath for a tableview when each cell height is dynamic?

The way Apple implements UITableView is not intuitive to everyone and it’s easy to misunderstand the role of heightForRowAtIndexPath:. The general intention is that this is a faster and light-on-memory method that can be called for every row in the table quite frequently. This contrasts with cellForRowAtIndexPath: which is often slower and more memory intensive, … Read more

How to keep UITableView contentoffset after calling -reloadData

I was having trouble with this because I mess with cell sizing in my cellForRowAtIndexPath method. I noticed that the sizing information was off after doing reloadData, so I realized I needed to force it to layout immediately before setting the content offset back. CGPoint offset = tableView.contentOffset; [tableView.messageTable reloadData]; [tableView layoutIfNeeded]; // Force layout … Read more

UITableview reloaddata with animation

To add to the correct answer, if you want to reload all sections in your UITableView you will need to do the following: ObjC NSRange range = NSMakeRange(0, [self numberOfSectionsInTableView:self.tableView]); NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range]; [self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationAutomatic]; Swift let range = NSMakeRange(0, self.tableView.numberOfSections) let sections = NSIndexSet(indexesIn: range) self.tableView.reloadSections(sections as IndexSet, with: .automatic) This … Read more

How can I tell when UITableView has completed ReloadData?

The reload happens during the next layout pass, which normally happens when you return control to the run loop (after, say, your button action or whatever returns). So one way to run something after the table view reloads is simply to force the table view to perform layout immediately: [self.tableView reloadData]; [self.tableView layoutIfNeeded]; NSIndexPath* indexPath … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)