Problem with uitableview background picture

Well, it's broken like on iOS 7 Beta 6.

At startup, I changed the background of the table view to an image (it does the same if I set it to color), and the table cells are white ...

When I select a cell, go to the next view, and then return to this view ... the cells are the same as the background of the view (except for the cell I selected) ...

Here I set the background ...

- (void)viewWillAppear:(BOOL)animated { pacListTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"dotted-pattern.png"]]; pacListTableView.backgroundView = nil; [super viewWillAppear:animated]; 

}

Any ideas? It works great on iOS and below.

+4
source share
2 answers

Try setting the background color in the table view cell to clear the color. Until the default iOS 7 background becomes transparent. But with iOS 7 it changed to white. Therefore, you need to manually install it to clear the color.

+5
source

With iOS7, by default the backgroundColor of the cell is white, not clearColor. You must explicitly set the desired backgroundColor in the cellView (not on the cell itself).

So in your case you will need to insert

 cell.contentView.backgroundColor = [UIColor clearColor]; 

inside

  - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
+1
source

Source: https://habr.com/ru/post/1498988/


All Articles