I have a table filled with tableviewcells that have an imageview as their highlight color.
Sometimes when I click on a cell, the imageview lags a bit to load. I was wondering how to reduce the lag?
I have the following:
cell.selectedBackgroundView = [DataSingleton sharedMySingleton].highlightView;
inside the method:
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
Note: I am calling the singleton every time I click on it. I will try setting the image locally to see if that makes a difference.
EDIT: So I set the imageview locally in viewDidLoad, and it seems to react a lot faster. I guess my problem is the singleton, but I want to be able to change all the highlight images at once. Is there a way to have a global variable that will load fast?
I am not much sure but below may help in performance.
Instead of writing your code in willDisplayCell method. You can write in cellForRowIndexPath method.
something like this
The idea is set selectedbackgroundView only once when you allocate memory for that cell. You need to use reuseidentifier for this.
Hope this help.