I have an reader application which have a night mode view,that is if the user tap the UISwitch button to on it turns out the background of the tableview ,text label.text and a label called chapetrandverse to black every thing works perfect,but the bug is when i tap the UIswitch to on ,the background doesn’t changes first ,we have to scroll the tableview to activate this effect.there is a black image in the background f the tableview .my code is
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
readCell *cell = (readCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"readCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
if (imagedarkbackground.hidden == NO)
{
cell.chapterAndVerse.backgroundColor= [UIColor clearColor];
cell.chapterAndVerse.textColor = [UIColor whiteColor];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.highlightedTextColor = [UIColor whiteColor];
//cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:16];
}
else if (imagedarkbackground.hidden == YES)
{
cell.chapterAndVerse.backgroundColor= [UIColor whiteColor];
cell.chapterAndVerse.textColor = [UIColor brownColor];
cell.textLabel.textColor = [UIColor darkGrayColor];
cell.textLabel.highlightedTextColor = [UIColor darkGrayColor];
}
Is there any issue in my code?why i want to scroll to change the lowlight effect? .
thanks in advance.
cellForRowAtIndexPath only gets called when the cells are scrolled into view. You will need to have the tableView reload or refresh the cells that are visible. Check the documentation for more details.